Float>float doesn't reset

Kind of a noob problem, but I can’t for the life of me solve it.

What I’ve basically done is a system that sets “Value” as the Game Time, and I want to subtract 5 to it when it reaches 5 seconds (basically cycle from 0 to 5)

This is how I set it up.

It works when Value reaches 5 the first time, but after that…

This happens. As you can see, Value is clearly less than 5, but the “greater than” boolean doesn’t reset properly.

Have I done something wrong?

Hm, if “Get Game Time in Seconds” reaches 5, the Branch will reduce the Value by 5. BUT "Get Game Time in seconds is till greater than 5. So it will set the Value to >5, the branch checks if its greater and returns true, the value is reduced by 5 and the frame ends. Next frame, the value will be set to “Get Game Time in Seconds” which is still greater than 5 and so on. Endless circle.

What you need to do is, use the delta time to add 1 each second to Value.

So you take “Get Value” + (1 * Delta Seconds) → “Set Value”. So you multiply 1 with the Delta Seconds and add it to the existing Value. Now you set the Value to this. And i would move this whole “Set” thing i just described behind the FALSE exec of the branch, so it will only be calculated if Value is less than 5.

I guess this would work (: If not, just tell me and i will have a deeper look on it.

The problem you have is that you are using Get Game Time in Seconds node. This timer can never be reset. You can pause it I think. So your timer may get reset for the fraction of a second but it immediately gets set to the game timer which is ever going up. Basically, your Value float is always higher then 5 after the first reset, but because right after the branch you set the value back to 0, you can still see it as 1 or anything lower then 5, but it gets set back up to game time which is always > then 5.

So I made a quick little blueprint that does what you seem to be wanting. It counts to 5 and then resets.
I hope this helped!

This worked! Thanks a lot! :smiley: