- Home /
PhotonNetwork.LoadLevel is working Only on Masterclient.
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());
}
}
}
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" is handled in another script.
Anyone else had same problem and found solution ??
Thanks in advance.
Answer by FlippingFlopper · Aug 28, 2018 at 10:14 AM
I Found out why.!
I was gonna make a shuffle for next map, but the scene that I was working on is the first one, and no any other map exists yet. So room custom property "Map" was containing current scene always. so if you call same scene as current one with PhotonNetwork.LoadLevel, It works only on masterclient.
Hope it will help someone else later.
Answer by ClearRoseOfWar · Jan 28 at 03:16 PM
Sorry to necro this, but Is there a work around for this? I came across this when I tried to do a similar idea.
When I reload the scene, it only reloads the masters scene. how to reload the same scene and have all players join in async?
PhotonNetowrk.LoadLevel(0); // reload the scene with players in it