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. Dismiss Notice

Actions with multiple bindings best practice

Discussion in 'Input System' started by WorldEater, Nov 4, 2019.

  1. WorldEater

    WorldEater

    Joined:
    Oct 23, 2014
    Posts:
    7
    What are the best practices when it comes to actions where two or more bindings are required to preform the action? Say for example i want to have a save action for a level editor be triggered when the *Left CTRL* and *S* key are pressed simultaneously. And to complicate things, both keys trigger other actions when pressed separately.

    In a such a scenario do I have to write my own logic to handle this kind of binding or is there functionality built in that I have missed? If not the appeal of Actions is somewhat diluted in my eyes.
     
  2. Jichaels

    Jichaels

    Joined:
    Dec 27, 2018
    Posts:
    237
    On your action asset, you can create a "Button with one modifier", or two modifier. I think that is what you're looking for
     
  3. WorldEater

    WorldEater

    Joined:
    Oct 23, 2014
    Posts:
    7
    Hmm, yes I was exploring that functionality, however if I use this option for the example i posted I would also have to have modifiers on the Actions connected to *S* and *Left CTRL* keys to make sure they are not triggered when both keys are pressed at the same time? This seems like a hassle if you have multiple shortcut commands in the application.
     
  4. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Yup, indeed. ATM we don't have a built-in solution for that. We have it on the list for after 1.0 as part of a wider look on having actions triggered more selectively. Something that solves both the problem here as well as problems such as UI actions preventing gameplay actions bound to the same controls from triggering. In 1.0, this is a notable hole in the action system.
     
    WorldEater likes this.
  5. WorldEater

    WorldEater

    Joined:
    Oct 23, 2014
    Posts:
    7
    Ok, thanks for the info! Good to hear it's in the works.
     
  6. abouskine

    abouskine

    Joined:
    Dec 11, 2021
    Posts:
    1
    Any news ?

    Currently I'm checking Keyboard.current.*key.isPressed to avoid this behaviour


     
    Last edited: Dec 11, 2021