Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Feedback InputUser.valid is always false when joining a player manually with paired devices

Discussion in 'Input System' started by moose0847, Oct 25, 2021.

  1. moose0847

    moose0847

    Joined:
    Dec 26, 2019
    Posts:
    33
    I'm currently working on setting up some local multiplayer for my game, for which I'm using the PlayerInputManager and PlayerInput scripts. I would like to manually join players, and so I've set my PlayerInputManager's joining behavior to "JoinPlayersManually", and am calling JoinPlayer in my script.

    This works just fine and creates the player prefab when I just set the player index, but when I supply devices to be paired with the player input, it causes the prefab to get automatically deleted.

    Code (CSharp):
    1. // This works
    2. _playerInputManager.JoinPlayer(0);
    3.  
    4. // These cause the player to get instantiated, and immediately deleted
    5. _playerInputManager.JoinPlayer(0, default, default, device);
    6. _playerInputManager.JoinPlayer(0, default, default, InputSystem.devices.ToArray());
    I've taken a look into the source, and this causes the object to be destroyed immediately because playerInput.user.valid is always false in PlayerInput.DoInstantiate. Has anyone encountered this issue before? I'm not seeing anything online as to what might the cause of the issue be.
     
  2. moose0847

    moose0847

    Joined:
    Dec 26, 2019
    Posts:
    33
    As is tradition, I found the issue right after posting the thread! For those curious, the issue seems to be that I had control schemes defined in my input actions, in that case you must supply the control scheme to which to pair devices.

    I'm keeping the thread here in case any else encounters this. If anyone from unity comes across this, it would be great if we could get a warning or error here as this seems like it's just improper data setup that needs to be resolved by the user.
     
  3. StupydHors

    StupydHors

    Joined:
    Oct 25, 2016
    Posts:
    25
    Just bumping this at it's still an issue. Had it not been for this thread I would have probably torn my hair out.