Search Unity

WASD two buttons pressed simultaneously

Discussion in 'Input System' started by JosephSelahJr, Jun 18, 2021.

  1. JosephSelahJr

    JosephSelahJr

    Joined:
    Oct 1, 2020
    Posts:
    18
    I didn't find anything relevant in previous posts aside from a possible bug from 2 years ago. But I suspect this is a configuration issue.


    Here's my scenario
    If I press one button and while it's held down, press another WASD key, the second doesn't fire an event. Both events fire if I press a key that's mapped separately. For instance, W & E -> both fire. It seems to be particularly an issue with sub actions.

    I'm using the new input system.
    I'm using broadcast messages for the behavior.
    For my
    Move 
    action, I have Action Type set to Pass Through and Control Type set to Vector 2
    For sub action
    WASD
    , I have Composite Type set to 2D Vector and Mode set to Digital Normalized

    Any ideas?
     
    Last edited: Jun 19, 2021
  2. steinbitglis

    steinbitglis

    Joined:
    Sep 22, 2011
    Posts:
    254
    The Vector2 Composite doesn't account for this situation. You will just have to handle it yourself. It's easy to create custom composites though.
     
  3. JosephSelahJr

    JosephSelahJr

    Joined:
    Oct 1, 2020
    Posts:
    18
    So essentially, I'll need to map each key separately? Will that cause problems for DPad setups?
     
  4. steinbitglis

    steinbitglis

    Joined:
    Sep 22, 2011
    Posts:
    254
    No, I think that Vector2Composite will read the 'A' key, find that it is pressed, and simply return with x = -1, regardless of the 'D' key.

    What you can do instead, is let the most recent key win. @Baste has written a composite that does this here.
     
  5. JosephSelahJr

    JosephSelahJr

    Joined:
    Oct 1, 2020
    Posts:
    18
    Thanks! I'll check out that thread. It actually looked like the event wasn't firing when I pressed the second key. Maybe I have two issues going on here.