PhotonNetwork.LoadLevel is working only on MasterClient

Options
Hello. I made a script to load new game. It works perfect, but ONLY on Masterclient. All other clients are remaining on previous scene.

the room custom property "Status" and "Map" are handled in another script.

Anyone else had same problem and found solution ??

Thanks in advance.


------------------------------------------------------------------------------


using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NewGameLoader : MonoBehaviour {

private bool loadNewGameOnce = true;

void Start () {
PhotonNetwork.automaticallySyncScene = true;
}

void Update () {
if (PhotonNetwork.room.customProperties["Status"].ToString() == "Restarting") {
if (loadNewGameOnce == true) {
NewGame ();
loadNewGameOnce = false;
}
}
}



void NewGame () {
if (PhotonNetwork.isMasterClient) {
PhotonNetwork.LoadLevel(PhotonNetwork.room.customProperties["Map"].ToString());
}
}

}

Comments

  • Hi @FlippingFlop,

    since you have a State called 'restarting'; I would assume that you are trying to load the same level again, don't you? In this case, the Custom Room Property for the level is not changed, which means that no clients will load any other scene, except the MasterClient who calls the LoadLevel function explicitly. If you want to load the same again, you would have to tell the non-MasterClients in a different way, for example by using another Custom Room Property or raise a custom event, which might be better in this case.