XR player freezes when another leaves the room. What is the reason?

I'm working on a XR multiplayer 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 30 has not changed anything. The player disappears when he leaves the room regardless of this line.


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.

Answers

  • The code you shared has nothing to do with what is happening.

    The input you locally get with the headset and controllers needs to applied to a character. In best case, this character's movement and positioning of head and hands is being synchronized. A typical problem is that each user instantiates the same prefab but only one should get input applied (the "local" one). I would search for the problem in that "area".

  • It's like you said. The inputs are tied to the local player for each player. For this we had to rewrite some XR Toolkit scripts. This works fine, but as soon as a player leaves the room it doesn't work anymore.


    I looked at components like the input action manager and the locomotion system. However, I have not been able to find any clues as to what the problem is. Those are really the only components, with the character controller driver, that we haven't rewritten yet.

  • 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.

  • Glad you found a workaround.

    Do you need more than one XR Origin? Could you split the Input Action Manager from the XR Origin maybe and not have duplicates, which then give you issues when someone leaves?