How to sync levels
I know I can use
PhotonNetwork.automaticallySyncScene = true;
This makes sure we can use PhotonNetwork.LoadLevel() on the master client and all clients in the same room sync their level automatically
PhotonNetwork.LoadLevel(nextLevelName);
Then I tested if isMasterCliente
void Update() {
if (PhotonNetwork.isMasterClient == false)
{
return;
}
if (levelCompleted)
{
StartCoroutine(LoadNextLevel());
}
}
POBLEM: My doubt is, How can I syncronize this boolean "levelCompleted" between players because I noticed in singleplayer it is working perfect but with multiplayer more than one player is setting levelcompleted and this can load more than one time a level
PhotonNetwork.automaticallySyncScene = true;
This makes sure we can use PhotonNetwork.LoadLevel() on the master client and all clients in the same room sync their level automatically
PhotonNetwork.LoadLevel(nextLevelName);
Then I tested if isMasterCliente
void Update() {
if (PhotonNetwork.isMasterClient == false)
{
return;
}
if (levelCompleted)
{
StartCoroutine(LoadNextLevel());
}
}
POBLEM: My doubt is, How can I syncronize this boolean "levelCompleted" between players because I noticed in singleplayer it is working perfect but with multiplayer more than one player is setting levelcompleted and this can load more than one time a level
0
Comments
-
Room custom properties is the best way to share information (data) between players?
Because I am thinking to put the boolean "levelCompleted" in a custom propertie of the room but I dont know if this is the correct.0 -
///
protected void SetLevelCompleted()
/// This method is storing "Level Completed" in the rooms custom properties
/// Since PhotonNetwork.time is synchronized between all players, we can use this to
/// share time information between all players
///
{
ExitGames.Client.Photon.Hashtable newProperties = new ExitGames.Client.Photon.Hashtable();
newProperties.Add("LevelCompleted", false);
PhotonNetwork.room.SetCustomProperties(newProperties);
}0