How to sync levels

Massive
Massive
edited May 2016 in DotNet
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

Comments

  • Massive
    Massive
    edited May 2016
    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.
  • ///
    /// 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
    ///
    protected void SetLevelCompleted()
    {
    ExitGames.Client.Photon.Hashtable newProperties = new ExitGames.Client.Photon.Hashtable();
    newProperties.Add("LevelCompleted", false);

    PhotonNetwork.room.SetCustomProperties(newProperties);
    }