Click and Hold to do Action

Hey Guys

This is probably real simple. You know how in games where you have to hold down a key or mouse button for a few seconds to perform an action which fills a round circle for example, how is this done?

It’s probably something to do with timers and widgets to show the progress, but am unsure on the basics of setting this up.

Let’s just say for example, I want the player to hold down the ‘E’ Key for 3 seconds and show the progress, how would I go about setting this up?

Any help would be greatly appreciated.

you need an event tick and a gate to preform such setup.

I never done it before but that’s how it should be done.

let me do an example for you.

Ok.

you need to create a variable in your Character BP or Controller ← doesn’t matter but in my example I did it on the controller.
create a variable and call it “Timer” and make it a float also leave it at 0.0 don’t set it make it editable and exposed on spawn.

in your main HUD/Widget blueprint add a Bar to your panel and check “Is Variable” true also call it “Test Bar” and set it to hidden. now this part is done.

go to your character bp or controller and do as below picture.

You can mess around with the “+” which is set to 0.01 or put a delay after the gate exit and set the delay to 1 second to get whatever result you’re looking for

Very interesting. Thanks for you response Okja. I will test it out and see how I go. I forgot all about gates.

don’t forget to bind the percentage bar with the float you created in your controller / character bp.

get player controller > cast to topdowncontroller > get “Variable” time and hook it up.