Syncing Level Change

I want all clients in the room to reload the level once a certain guideline is met. The guideline is met just fine and debug statements print out that it is so. I have set PhotonNetwork.automaticallySyncScene as true under the master client, but the issue is, when I do PhotonNetwork.loadLevel using the current level, Application.loadedLevel, only the master client reloads the level, seemingly because only the master calls load level. When the level is reloaded, messages from other clients are sent to the master client and neither client knows how to handle these messages because they are not in the same level. How do I sync a reload of the level?

Comments

  • Ah yes, automaticallySyncScene currently only checks if the scene string has changed. So it cannot detect a reload currently.

    As a quick fix for you, run this on the Master Client:



    [code2=csharp]StartCoroutine(ForceReload());//Run this on the MC

    IEnumerator ForceReload(){
    if(PhotonNetwork.isMasterClient){
    photonView.RPC("DoReload", PhotonTargets.Others);
    PhotonNetwork.networkingPeer.Service(); //Make sure to send the RPC before starting loading ourselves
    yield return 0; //Wait 1 frame for sending, not sure if this is required.
    PhotonNetwork.LoadLevel(Application.loadedLevel);

    }
    }

    [RPC]
    void DoReload(){
    Application.LoadLevel(Application.loadedLevel);
    }[/code2]