Follow the transport installation guide to add the Photon Realtime Transport to your project.
Once added, please follow the following steps
-
Access Wizard from Window → Photon Realtime → Wizard
-
Click next until you get to the Photon Cloud Setup Part
-
To complete the setup, you need a "Photon Realtime" AppId. If you know yours, enter it and click the Setup button. Alternatively, enter your email address and click Setup. If possible, a new Photon account gets created (more information in the License) and the AppId is fetched. This completes the setup. If you already got a Photon account, the Wizard can't fetch the AppId, so click the "Visit Dashboard" button and login to the Dashboard to access your AppIds.
-
If you just created an account for the first time you need to also create a New Application from Photon's Dashboard
Note: The Photon Type for this transport is:
Photon Realtime
-
Once an Application is setup, you will be able to get it's AppID from Photon's Dashboard, copy that to your clipboard
Note: To connect others to your Photon Room, the AppId must be the same in all clients!
-
Go back to the Photon Wizard Window of your Unity Project and paste the App Id there
-
Click on Setup
-
It should show something like: "Your AppId is now applied to this Project Done "
-
Click on Next, then Done, you should be all setup now!
-
You can safely quit the Photon Wizard now!
Follow these steps in order to prepare your Unity to be packaged and distributed to your audience:
-
Find
PhotonAppSettings
asset in your project -
The AppId you've set during the setup, should be shared with your friends in case they want to use the Unity Editor, instead of a packaged built, as each developer might have a different AppId/region set in its PhotonAppSettings asset.
Note: We suggest considering Playing in Editor with your friends only for iteration purposes (when they have access to your project) as we encourage you to distribute your packaged builds to your friends, because sometimes they might have some local changes that would cause different issues.
-
Select the closest region (token) to where you want to host your session from, you can check out a full list here:
Note: As an example, if I would like to host a session/room for players within Europe, then according to the table above the closest location/data centre would be the one from Amsterdam, hence, the token for it is "eu"
-
Once a region token is chosen, put it in the PhotonAppSettings asset of your project in the Fixed Region field.
IMPORTANT All of your friends/users should have the same region set in their PhotonAppSettings asset, otherwise they will not be able to find nor connect to your room/session, in case they are using a Unity Editor.
- Add the
PhotonRealtimeTransport
component to your GameObject containing your NetworkManager. - Set the
Network Transport
field on the NetworkManager to thePhotonRealtimeTransport
- Enter a room name into the
Room Name
field of thePhotonRealtimeTransport
. - Use the
StartHost
andStartClient
functions as usually to host a game and have clients connect to it.
While a static room name works fine it will put all your players into the same room. You have to write your own logic to set the RoomName
property of the PhotonRealtimeTransport
and share that name with all players interested in joining the same room. There is no built in matchmaking currently.
Documentation about other settings can be found in the Photon Documentation.
Your project should be ready to be packaged and distributed!