Forum rules - please read before posting.

Detecting key press via ActionList

edited September 2018 in Technical Q&A
Unity Ver: 2018.2.2f1
AC Ver: 1.64.1

Hello,

For a bit of onboarding I'm wanting to detect via actionList if the player has pressed a certain key (in this case W) and if so remove a menu prompt.

I've setup an actionlist like this:


In this case the menu appears but never disappears. If the 'Equal to' value is set to 0 the menu will dissappear immediately. If I set to 'greater than 0' the condition is never met.

Where am I going wrong here?


Thanks,
T

Comments

  • Try looping the check back on itself so it continues checking until the key is pressed.
  • edited September 2018
    @KevRev That fixed it. Good catch! I assumed the actionList 'Input:check' would have been looping internally in some way, but it makes perfect sense that isn't the case given the not met condition outcome. Really useful learning there. Thanks.

    Working version:




  • You're welcome. I'm new too, so its good to be able to share things i've figured out :)
  • Looping ActionLists to detect inputs isn't recommended.  Instead, rely on "Active Inputs", which trigger ActionLists upon detection.  For more, see the Manual chapter by the same name.
  • edited September 2018
    Thanks. I'll have a look into those.
    Out of curiosity why isn't looping ActionLists recommended?
  • I'm having no joy getting Active inputs to work as desired. Here's my setup:


    1. The Active Input

    image

    This is what I have setup for the active input. I want it to register a press of just 'w'. I don't want it enabled from the very start. The idea is to enable it at the appropiate moment via a ActionList.


    2. Enable Active Input

    image

    During my tutorial I show a menu and toggle (which I assume enables in this case) the active input.


    3. ActiveInput ActionList

    image

    Here's what the active input should trigger (its attached ActionList). None of this happens which means the active input either isn't being enabled, or, its not registering any input.
  • Please see the note in the Manual chapter - the "Input button" field refers to the entry in Unity's Input Manager, not the keyboard key it's mapped to.  You must define "w" in your Input Manager for it to register as an active input.

  • Indeed. I've also tried that to no success. Setting the input type to both button and axis;





    I've tried various threshold settings for the Axis option to no avail.


  • Your Input: Toggle active Action doesn't enable the active input - you need to check the New state field.

    To test it without the need for this Action, you can check Enabled by default? in the Active Inputs window.
  • 'New state' sorted it.

    2/2 fixes Chris. Thanks!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.