Search Unity

Bug Composite "overrides" not working as expected

Discussion in 'Input System' started by Tryptic_CK, Nov 17, 2022.

  1. Tryptic_CK

    Tryptic_CK

    Joined:
    Feb 6, 2021
    Posts:
    6
    Under the section Conflicting Inputs subsection Multiple input sequences (such as keyboard shortcuts) the documentation for Input System 1.4.4 states that "Bindings will be processed in the order of decreasing 'complexity'" and "the first Binding that results in the Action changing phase will "consume" the input.". This does not appear to be functioning as intended, at least under Linux (Ubuntu 22.04). Not only is the input not being consumed, but the actions are being triggered in the opposite of the expected order.

    The following actions can be taken to reproduce.

    Create an action map with 2 bindings
    Click
    Left Button [Mouse]

    ShiftClick

    Modifier: Left Shift [Keyboard]
    Binding: Left Button [Mouse]

    Create a MonoBehaviour script with 2 functions
    Code (CSharp):
    1. public void OnClick(InputAction.CallbackContext context) {
    2.   Debug.Log("Click");
    3. }
    4.  
    5. public void OnShiftClick(InputAction.CallbackContext context) {
    6.   Debug.Log("ShiftClick");
    7. }
    Assign the above functions to their corresponding events in the PlayerInput component

    In play mode press the Left Shift key followed by the Left Mouse Button

    Expected output

    ShiftClick
    ShiftClick
    ShiftClick

    Actual output
    Click
    ShiftClick
    Click
    ShiftClick
    Click
    ShiftClick
     
  2. PatrickAtKingart

    PatrickAtKingart

    Joined:
    Aug 29, 2019
    Posts:
    1
    The same problem also occurs on Windows with "Unity 2022.2.15" and "Input System 1.5.1".
     
  3. unormal

    unormal

    Joined:
    Jan 10, 2012
    Posts:
    65
    The built in modifier consumption handling is completely broken, you should absolutely not use it, and they are closing sev1 bugs filed against it as "by design". You need to handle modifiers yourself. There are extremely severe bugs in it, for example enabling/disabling a layer with a modifier key in it during an update frame when a modifier key is held will break all future checks of that modifier.

    In Caves of Qud, for each action we create a set of subactions, one per modifier combination, and in a frame only check the appropriate subaction set that matches the currently held modifiers.
     
  4. Bankaru

    Bankaru

    Joined:
    May 7, 2022
    Posts:
    1
    I was running into this problem today and thought I must be doing something wrong. Documentation should be changed if it doesn't work...