[Enhanced Input] Two Different Triggers For Two Different Logics On One Button

HELLO everyone!!!
I am now one step away from finally understanding the Enhanced Input System :sweat_smile:
What is the actual problem/question:
I don’t really understand how to separate the trigger logic.
Namely: I need if the player pressed the button(‘E’), he just interacted with the object. BUT!!! if he hold this button called a radial menu with certain actions on this object (those who played in ARK: Survival Evolved will understand what I mean).
Help please!

output

Hi @blAddddDe,

You can call two different events from the same key depending on how you setup your triggers. Here I have the player kicking the box with tapping the E key and changing the size of the box when they hold the E key.


I created two new input actions: IA_Kick and IA_ChangeSize


In my InputMappingContext, I added those two input actions to the mapping array. Then I set the values as above.

Since you want to use the same key for both, it’s important to set the “just interact” action to Tap and not Press.

  • The Press event triggers when the key goes down, so that will always fire, even if the player is trying to do a hold action.
  • The Tap event fires if the key is pressed and released quickly - here within 0.2 seconds.

That allows us to set the other action to be hold, and set a pretty low time threshold - here 0.25 seconds - so it still feels fairly quick to the player.


Then in my character class, I can just right click for a new node, type in “kick” or “changesize”, and hook up whatever logic I want.

Hope this helps!

1 Like

Thank you!