This guide shows how to set up Photon Multiplayer to work with PlayFab. Currently, PlayFab offers
Photon matchmaking tutorial following Photon integrations:. We will illustrate how both features work using latest Photon Unity example project. Setting up Photon Application Once you have registered and logged into Photon Dashboard, create a new app Select "Realtime" application type 1pick a name 2 and description 3.
by clicking "Create" Application dashboard will open.
Find and save the App Id
Photon matchmaking tutorial located under the page title:. Then locate "Authentication" section 1 and select "Custom Server" Setting up PlayFab title for Photon Navigate to your title game manager page. Optionally, you may specify Chat Application Id. Once you install the add-on 3Secret Key will be generated 2.
Save it, as it will come in handy when configuring web-hooks: This is done by means of Web-hooks: A path
Photon matchmaking tutorial, effectively, a handler name
Photon matchmaking tutorial in your Cloud Script. Fill in the base
Photon matchmaking tutorial 1. Assign Cloud handler name for each of available events 2.
Photon matchmaking tutorial any CustomHttpHeaders 3. Submit by clicking "Save" Start by navigating Photon matchmaking tutorial the asset store.
You may inspect the imported files. Then click "Import" Once the setup finishes, click "Done" Unity project window will reveal the Photon matchmaking tutorial 3 object. Click the object to Photon matchmaking tutorial it's settings in the Unity inspector window:. Implementing PlayFab to Photon authentication When you enable Photon add-on for your title and configure authentication on Photon Application Dashboard, PlayFab allows you to authenticate existing PlayFab players inside the photon environment.
This means you may completely avoid implementing any user management for Photon. This feature requires minimum setup in Unity. This scene is, indeed, a hub for all the examples from the package.
It is Photon matchmaking tutorial first scene to load, so let us add small script to enable PlayFab to Photon authentication. The code for PlayFabAuthenticator component is the following Photon matchmaking tutorial, read the comments for the Photon matchmaking tutorial. Photon will start outputting debug messages.
Thus, by monitoring your console you can easily spot if you have any authentication issue:. Ensure that no "Authentication Denied" errors present in the console. At this point, have set up minimal PlayFab and Photon integration. If you are not familiar with this concept, please consult with the Photon Matchmaking Guide.
PlayFab allows to intercept various room events. The following room events require only Cloud Script to be intercepted. The following events will require additional control over unity code to be intercepted details are later in
Photon matchmaking tutorial document:.
Once you introduce a handler for room event, it becomes essential part of event handling flow. Thus, errors produced while running your Cloud Script may cause problems for the entire system. For example, if "RoomCreated' handler throws an error, your clients will throw an error as well and will not be able to connect properly. Let us construct PlayFab Cloud Script by defining handler for each event type one by one. The following Cloud Script handler will intercept such event.
Photon matchmaking tutorial acquire additional data about the event using 'args' argument. The example of 'args' payload is given below:. The following Cloud Script handler will
Photon matchmaking tutorial such event:.
This callback is not invoked for the very first Photon matchmaking tutorial entering the room. Use "Room created" to intercept the first player join. The following Cloud Script handler will intercept such event: If room property was changed from the client, you may Photon matchmaking tutorial 'args' argument and refer to 'UserId' to acquire the player in charge.
When changing custom room properties using Unity Photon client, it is important to mark the call so, that it passes the event to WebHook PlayFab
Photon matchmaking tutorial this case:. When raising custom room events using Unity Photon client, it is important mark the call so, that it passes the event to WebHook PlayFab in this case:.
The code about does nothing more than posting Photon matchmaking tutorial title event whenever Photon callback is invoked.
Photon matchmaking tutorial
Being of no use in production, this example will let us clearly see how the callbacks are invoked. Extend the PlayFabAuthenticator script by including new example code that will raise custom event and set custom room property. The extended version also utilizes Photon matchmaking tutorial method to not destroy object between scene loads:.
Run the hub scene and wait for PlayFab authentication to 1 then load the Boxes Demo Once the Photon matchmaking tutorial loads, wait for the peer to connect newly created room 1then click "Execute Example" in the top left corner 2then observe the console output 3 and make sure no errors pop up. Do not forget Photon matchmaking tutorial stop Unity from playing.
This is to ensure we Photon matchmaking tutorial receive "RoomLeft" and Photon matchmaking tutorial events. You should be able to see events generated as a result of our Cloud Script code Photon matchmaking tutorial Photon events. Documentation Home tutorials tournaments Getting started with Photon and Unity Did you find this helpful?
Currently, PlayFab offers the following Photon integrations: Setting up Photon Application Once you have registered and logged into Photon Dashboard, create a new app 1: DeviceUniqueIdentifier as our custom ID.
Photon matchmaking tutorial create new AuthenticationValues instance. Do not let it confuse you: PlayFab expects it to contain Photon Authentication Token issues to your during previous step. Empty in this case, because our property has not existed before.
SetCustomProperties properties, expectedProperties, true. Generic; using PlayFab; using PlayFab.