Search Unity

Question [New Input System] Composite Vector2 that prioritizes last press instead of combining inputs?

Discussion in 'Input System' started by pastaluego, May 27, 2023.

  1. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    196
    Right now if you make a Composite Vector2 InputAction named 'Movement' that has Left/Right/Up/Down composite bindings, if you press left and right at the same time, it combines -1 and 1 so Movement.ReadValue<Vector2>().x returns 0.

    How would I be able to determine that when both are pressed, the Left binding is -1 and Right binding is 1? Because I need to know the actual 'pressed' values of both the Left and Right specifically when they're both pressed and not just their combined output, because with ReadValue<Vector2>().x, pressing Left + Right is virtually identical to pressing nothing so there's no way for me to know if Left and Right are being pressed.

    Is there some sort of way to do Movement.ReadValue<float>(bindingIndex) for a 2D Composite? Because that would solve my issue immediately. It is odd that there isn't a way to obtain the direct underlying button values that make up a composite InputAction.
     
    Last edited: May 27, 2023