Simple way to countdown from 100 during key press?


I’ve been wrapping my head around timers, timelines, event tick delta seconds, etc. I still cannot seem to find a good solution for this. Essentially I have a meter, say with a value of 100, and whenever the player is pressing a key input, I want to decrease this meter by a certain amount every second. What is the optimal way to blueprint this?

I tried continually storing Event Tick Delta Seconds and when the key is pressed… somehow… decrementing for each second that elapses. But I just cannot seem to do this properly…

Any help is greatly appreciated… the example that would put me in the right direction would simply take a key press and as long as that key is pressed, decrease a float by one for every one second it is pressed until it gets to 0.

Thanks for any assistance.

This should work, There’s probably many different ways you can do it. The number integer will lower by 1 every second that the enter button is pressed. You can abuse this by repeatedly pressing enter though, if this is not intended then you might want to move the delay to run before the set node so they can only move it one time per second which is what I did in the second example.

Here’s an example on how you an do this using Delta Time.

Every Tick you multiply ChangeRate with Delta Seconds. This means the ChangeRate is a per second type of value (in my example the meter will change with 10 per second).
After that you take the result and subtract from the Meter value. You may want to add functionality to reset the Meter and so on. Also you can simply set default values on Meter and ChangeRate, you don’t need the BeginPlay node but it makes it easier to screenshot.

Worked like a charm for me. Coupling the delay with the boolean was a good call. Thanks!