I’m working on a XR multiplayer (PUN2) project from my studies and can’t figure out why my player freezes when someone else leaves the room.
Here is the scenario:
P1 enters the room. P2 joins. When one of the two players leaves the room, the remaining players freeze. Means: They can’t move their hands anymore and they can’t walk. The head/camera works means they can look around. If now another player enters the room everything is back to normal.
The code below is the logic I use within the rooms. Line 20 has not changed anything. The player disappears when he leaves the room regardless of this line.
public class GameManager : MonoBehaviourPunCallbacks
{
[SerializeField] private GameObject networkPlayerPrefab;
private GameObject spawnedPlayer; // local Player
public void LeaveRoom()
{
PhotonNetwork.LeaveRoom();
}
#region Photon
public override void OnJoinedRoom()
{
spawnedPlayer = PhotonNetwork.Instantiate(networkPlayerPrefab.name, transform.position, Quaternion.identity);
}
public override void OnLeftRoom()
{
base.OnLeftRoom();
//PhotonNetwork.Destroy(spawnedPlayer);
SceneManager.LoadScene(0);
}
public override void OnPlayerEnteredRoom(Player newPlayer)
{
base.OnPlayerEnteredRoom(newPlayer);
Debug.LogFormat("Beigetreten {0}", newPlayer.NickName); // Sieht man nicht wenn man selber der Spieler ist
}
public override void OnPlayerLeftRoom(Player otherPlayer)
{
base.OnPlayerLeftRoom(otherPlayer);
Debug.LogFormat("Verlassen: {0}", otherPlayer.NickName); // Sieht man nicht wenn man selber der Spieler ist
}
#endregion
Has anyone had similar experiences or any idea what the problem might be? I think it could be specifically the XR Toolkit (2.0) scripts.