Reset countdown timer and apply times two damage every time countdown timer resets

What I am looking to do is every time my countdown timer which is set at 30, reaches zero, I want it to reset back to 30.
Not only that but when it reaches 0, I want the player to receive damage and every time it resets and drops to 0 it will again apply damage and keep looping like that.
Also every time it applies damage it will apply times 2 damage.

I will give an example.

My countdown clock is set to 30. When it reaches 30 I want to apply 5 damage. When the countdown timer resets and drops back down to 0 i want to apply 5X2 damage which equals 10. The next time it resets and drops to 0 I now want to apply 10x2 damage which equals 20 and just keep going like that higher and higher.

I have a screenshot but i know its completely wrong. It does what I want,but just one time.

I really would appreciate any help.
Thanks in advance.

I’d suggest you the SetTimerByFunctionName node. It creates a timer, and you can make it loop.

204306-settimerbyfunctionname.png

You just have to create a function, then call this node once (only once) by specifying the function name and the timer.

For the “double the damage each time” part, I would do a class variable to store the number of calls of that function, then multiply your damage by this number.

Also, I saw you put a delay, then decremented your variable. You should have directly substracted “DeltaSeconds” from your variable, since “DeltaSeconds” is the time since the last frame.
So basically, do this :
“Each frame, substract DeltaSeconds”
Instead of this :
“Each second, substract one second”
Anyway, with the SetTimerByFunctionName, you don’t have to use this kind of behaviour :slight_smile:

Hope it helped!

This is what I came up with. Its simple, but it seems to work perfectly.

Why did I happen to get a down vote for this?