Input action on button tap, another on hold?

Hey, I wanted to use the same button or key to fire an event if the button was pressed/held for less than 0.5 seconds, and another if it was released after being held for at least 0.5 seconds.

How can I do so with the enhanced input mapping?

add a Down trigger:

(where you see Pulse in the image below, set that to down)

From the event plug a print string into all the exec pins and then put that blueprint one second monitor or half screen and go into PIE. press the input and you’ll see the different execs fire to understand what they do. be sure that you have set the debug target in the blueprint toolbar so you can see execution flow live.

What you’ll see is that the trigger fires after your specified time interval. And the completed fires when you release.

SO you have two pieces of the puzzle. You know when it is released and you know when it has been for 0.5 seconds. All you need then is a way to remember this. A simple bool can do the trick.

Set a bool to true when the trigger fires and check this bool on release. if true, run your logic, if false dont.

Reset the bool to false after release.

Also be aware there is triggered seconds:
image
which you may use in conjunction with hold and release triggers.

1 Like

Thanks! It worked. This is what I did:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.