When the masterclient try to leave room its work if it 's not the masterclient doesnt work
Nadoc
✭
I want that when a player leaves the game the other players also leave
when the player leaving is the masterclient all players leave
when it 's not the masterclient the others leave it but not him
I DONT UNDERSTAND WHY
0
Answers
-
You need to implement
OnPlayerLeftRoom
, notOnPlayerDisconnected
.That should be all.
0 -
Its doesnt work with
OnPlayerLeftRoom
its the same problemif i m the masterclient its work allthe players return to lobby scene
if i m not the masterclient , the masterclient return to lobby scene and others stay in the same scene
public void BackToLobby() { StartCoroutine(LoadLobby()); } public override void OnPlayerLeftRoom(Player otherPlayer) { StartCoroutine(LoadLobby()); } public IEnumerator LoadLobby() { PhotonNetwork.Disconnect(); while (PhotonNetwork.IsConnectedAndReady) yield return null; SceneManager.LoadScene("Lobby"); }
0 -
I just wait 2 sec after leaving room and then load scene.
It worked for me
private LeaveRoom() { PhotonNetwork.LeaveRoom(); yield return new WaitForSeconds(2f); Debug.Log("No Maps Left"); SceneManager.LoadScene("Lobby", LoadSceneMode.Single); }
0