XR player freezes when another leaves the room.

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.

Update: It has nothing to do with Photon. The same thing happens when you create a second XR Origin player offline and destroy it.

The problem:
As soon as more than one XR Origin with an Input Action Manager is in the scene and one of them is destroyed, all inputs seem to be disabled.

Solution:
When destroying a player, I now searched for all Input Action Manager scripts in the scene and called “EnableInput()” once.

1 Like

Thank you for the helpful tips!

Hey! Thanks for your solution! I am facing the same issues but calling EnableInput() is not doing anything for me! any idea what else I could try over this? I’m stuck with this and weirdly when I am leaving the room its not even deleting the input action manager my local player has so I am not sure whats exactly happening

No worries! I found a fix! rather using individual Input Action Manager for each user I shifted to a more centralized version which was able to handle the inputs well without any bugs

While it doesn’t use PUN, I’d recommend checking out the VR Multiplayer Template. This Template uses NGO and UGS, but under the hood the same ideas will apply. For example, we only ever spawn in a single XR Rig. We then only replicate the tracking data over the network to each networked player.