Trying to end game when timer reaches 0

This is probably a pretty simple problem, but I’m really new to this so do pardon me.

I’m working off the FPS example project, and am basically trying to put a timer in there that counts down to 0, and ends the game once that happens.

I’ve already got a the timer counting down in HUD, but I can’t seem to end the game once it reaches 0.0. Am I doing something wrong here?
(By the way, the <= boolean gate should be 0.0, I had set it to 1.0 for testing but forgot to change it back. Doesn’t work either way.)

Also, this is in the FirstPersonGameMode BP, but I’m not even sure if something like this should be here or the Level BP.

Thanks in advance!

Hello parasitic,

To do this, it would help to create a custom event and use a timer to call that event every second. Have a look at my blueprint and see if copying that will get it to work for you.

Hope that helps. Have a great day,

Sean Flint

Thanks a lot Sean, that worked great!

Just a quick follow-up query though. Previously the one I had used allowed me to display the timer as a float on the HUD (e.g. 7.35 sec). However, this one seems to show whole numbers only (e.g. 7 sec).

The function I’ve bound to the HUD element remains the same, as follows, and I’ve tried all the Rounding Modes to no avail.

Is there something I’ve missed?

Thanks again!

Hello parasitic,

I’ve figured out the issue. Earlier, we were only subtracting one from the remaining time, which means the numbers would always be 10, 9, 8, and never have a decimal value. These new blueprints will fix that issue and allow you to have a countdown timer that displays decimal values on your screen.

Hope that helps, and have a great day,

Sean Flint

Thank you so much! That works perfect now. :slight_smile:

This is awesome, thank you. I will be implementing your BP code into my game this evening.

how do I get the Event Draw Hud Node it doesn’t show up

If you look at the Functions panel on the right-hand side of the HUD Blueprint, you should see the option to Override. Click the Override button, and you should see Receive Draw HUD as an overridable function.

Hope that helps.