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 Using the WASD keys prevents gamepad input.

Discussion in 'Input System' started by ElnuDev, Aug 8, 2019.

  1. ElnuDev

    ElnuDev

    Joined:
    Sep 24, 2017
    Posts:
    298
    I have a vehicle that can be moved by either the WASD keys, the arrow keys, or the left joystick on a gamepad, all of which are mapped to an action called
    Move
    in the new input system. I want to give the player the ability to switch between using keyboard and gamepad input during gameplay.

    My vehicle movement script works as follows. In
    LateUpdate
    , I execute
    Turn(controls.Game.Move.ReadValue<Vector2>().x);
    and
    Drive(controls.Game.Move.ReadValue<Vector2>().y);
    .

    Here is the
    Turn
    function:

    Code (CSharp):
    1. void Turn(float direction)
    2. {
    3.     if (direction != 0)
    4.     {
    5.         rb.angularVelocity = turningSpeed * -direction;
    6.     }
    7. }
    Here is the
    Drive
    function:

    Code (CSharp):
    1. void Drive(float direction)
    2. {
    3.     if (direction != 0)
    4.     {
    5.         rb.velocity = transform.up * movementSpeed * direction;
    6.     }
    7. }
    When I press play, the left joystick works perfectly. However, the WASD keys, arrow keys, and left joystick on the gamepad seem to interfere with each other. For example, if I move the vehicle with the joystick, then use the WASD keys, the joystick input stops working. Any ideas on fixing this? I'm really confused.

    I'm using Unity 2019.2.0f1 with Input System 0.9.0 and a Xbox One controller.

    Thanks in advance!
     
  2. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Could you give this a try with 0.9.1? (due out today)

    We had a regression in 0.9.0 that made composites not work correctly in combination with the control "disambiguation" code. Meaning, that the code behind actions that is supposed to figure out which input to let through when multiple controls are concurrently bound to a single action wasn't working right with composites and the end result would be that input was just getting stuck. Should be fixed now.
     
    recursive likes this.
  3. ElnuDev

    ElnuDev

    Joined:
    Sep 24, 2017
    Posts:
    298
    Okay, thanks! I'll give it a shot with 0.9.1.