Enhanced input, how to handle multiple triggers

I want to implement 2 types of attack: normal attack and strong attack. To do this I use enhanced input, I created two triggers: Tap - normal attack and Hold - strong attack.

How do I handle these triggers? Can I implement this on one input action or do I need to create two?


If you really want to use tap for some reason, the answer is below, but I highly recommend just getting rid of the tap trigger.

Tap is only useful if you want some middle case where you’ve held too long to light attack but to short to heavy attack- something that would probably feel clunky to the player.
Looking at your use case, you don’t want that.

You can drag off of cancelled and treat that as if you’ve tapped and use triggered for hold attack.

Either way, you’ll want to enable is one shot on the hold trigger:

Summary

You can check against the hold time threshold for the hold action.

We then can just check how long it was between pressing down the key and firing the event. If it’s longer than or equal to the hold duration, it was caused by hold- else it was caused by tap.


Keep in mind this will only get the triggers on the input action itself, not the context triggers.

3 Likes

Thanks for your help rokenrock, on your advice I left one Hold trigger. I really want the strong attack to be responsive, so I reduced the Hold Time Threshold to 0.2 seconds. As a result, Triggered triggers a strong attack, and Canceled triggers a normal attack.

4 Likes