When i use OnRoomPropertiesUpdate to loadscene, the other client will restart the scene multi times.
Hello, i have a question.
I use the following code to load level.
Is this a way to avoid this condition?
I use the following code to load level.
public override void OnRoomPropertiesUpdate(ExitGames.Client.Photon.Hashtable propertiesThatChanged) { object start_flag; if (propertiesThatChanged.TryGetValue("Match_Start", out start_flag)) { if ((bool)start_flag == true) { LoadingPanel.SetActive(true); if (PhotonNetwork.IsMasterClient) { PhotonNetwork.LoadLevel("Room for 8"); Debug.Log("Load Scene!"); } } } }After load to new level, the masterclient is fine, but the other clients will restart the scene, it means that these clients will execute twice OnStart trigger.
Is this a way to avoid this condition?
0
Answers
-
It's likely you set properties for the room multiple times and each time you include "Match_Start" as one of the key-values to change.
You can avoid that. Or you can come up with a local variable that keep track if the scene loading began.
Why not use the built-in scene sync? The Basics Tutorial makes use of it, for example:
https://doc.photonengine.com/en-US/pun/current/demos-and-tutorials/pun-basics-tutorial/lobby/0