Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Help Wanted Input System - don't unbind Input Devices when Player's GO is disabled

Discussion in 'Input System' started by MaturasPL, Aug 1, 2020.

  1. MaturasPL

    MaturasPL

    Joined:
    May 1, 2017
    Posts:
    2
    Hi, I'm using the newest release of Input System in my game and I've encountered the following problems:

    I'm making a local multiplayer game, so I have several players with Player Input components, each having their own bound Input Device (they're bound upon Instantiation). Since it's a competitive game where players die, when they die, I disable their GameObject and then re-enable it after some time. What I've noticed is that whenever I disable a player, his InputDevice gets unbound and then re-bound upon enabling the player again. It creates a problem when I force respawn all players, because their Input Devices get mixed up, example:

    I have Player A with bound Gamepad and Player B with bound Keyboard and Mouse
    I disable them and re-enable their GameObjects at the same time
    Player A gets bound with Keyboard and Mouse and Player B gets bound with Gamepad

    Is there a way to prevent this?
     
  2. MaturasPL

    MaturasPL

    Joined:
    May 1, 2017
    Posts:
    2
    Okay, so I've decided to avoid this problem by simply having the PlayerInput component (and the component with all necessary references and input event handlers) in a separate GameObject, that is always active (it's not a child of Player's transform).
     
unityunity