Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    Dismiss Notice

Mutually exclusive actions, or 'negating' composite modifiers?

Discussion in 'Input System' started by vecima, Apr 6, 2020.

  1. vecima

    vecima

    Joined:
    Jun 6, 2017
    Posts:
    16
    I'm trying to make UI tab navigation happen by creating "navigate next" and "navigate previous" actions.

    This is how I would (ideally) like them bound:
    UI (The action map)
    - NavigateNext (an Action)
    -- Right Shoulder [Gamepad]
    -- Tab [Keyboard]
    - NavigatePrevious (another Action)
    -- Left Shoulder [Gamepad]
    -- Button With One Modifier
    --- Modifier: Shift [Keyboard]
    --- Button: Tab [Keybaord]

    The gamepad portion of this works fine. The problem is that when I press Shift + Tab, both of these actions trigger. I understand why this is happening, as I am also pressing Tab, however this makes the desired result tricky to implement.

    I do have a manager class that defines methods like:
    /* NAVIGATE NEXT */
    public bool GetNavigateNext()
    {
    return this.navigateNextAction.triggered && !this.navigatePreviousAction.triggered;
    }

    /* NAVIGATE PREVIOUS */
    public bool GetNavigatePrevious()
    {
    return this.navigatePreviousAction.triggered;
    }

    This is not optimal, and only works when I use these calls - in any other place where I might map actions using an InputActionReference I would need to add similar logic. I did attempt to configure NavigateNext as a Button With One Modifier and on the Modifier (Shift) apply an "Invert" processor, but that did not work. It does work if I set it up so that NavigateNext is Ctrl+Tab and NavigatePrevoius is Shift+Tab, but this is not the desired outcome.

    Is there a way to map my NavigateNext action such that the Shift key must not be pressed in order for it to trigger? In other words "don't trigger if shift is held"? Or is there some other way to define my NavigateNext and NavigatePrevious actions as mutually exclusive?
     
  2. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Actions are currently not able to "pre-empt" each other's input. This is high up on the list for after 1.0 and probably one of the first things to get worked on. This will make it possible to deal with setups involving shortcut modifiers but also deal with the common problem of having the UI consuming input from actions preventing it from triggering input on game actions, too.