How to Connect and Instantiate your Player
Last updated
Last updated
Connect to photon is really simple, here is a quick guide of how to connect, create a room and finally instantiate a character:
First create a trigger with On Start igniter, after you create the trigger go ahead create actions. Add a Photon Connect action, you can leave parameters as they are.
Create another trigger with On Connection Events set the event type to On Connected To Master.
When photon is connected this event is going to be called. Let's add Join Or Create Action this will join a room o create if it doesn't exists.
We want to instantiate our player once we join room so let's add a On Photon Event trigger and set the event type to On Joined Room. Within the On Joined Room event now add Photon Instantiate action and select or assign your Character Prefab.
Don't know which method to use? You can see more in Instantiation Options
Player prefab can't be present on the scene they need to be Instantiated with the Photon Instantiate action
Pro Tip: You can enable your player Camera after player is instantiated.
You might want to have some feedback.
Let's add a text component to get the Photon Status but first we need the event. We can store the status/state in a local or global variable to later use this.
Finally add the text action and to show what we saved in a local variable.