I’m having trouble trying to create a countdown timer with Blueprints. As I’m not sure where to start with it.
I’m trying to create a timer that can be placed into individual levels, and will display on the Player’s HUD, the time remaining. (The reason I’d like it to be placeable and editable into different levels is that different levels will have different times required to complete them).
What I’m aiming to create is a time limit to complete the level, If the timer hits “0”, then a “Game over” with a “Restart” button appears.
Any help with this would be absolutely appreciated, Thanks!
Enjoy. This is my simple timer with 2 functions and 2 events. First event is for each tick and second is called when time is up.
On TimeIsUp event you can clear the timer(we saved a handle for it) to stop ticking or you can restart it(otherwise this event will keep firing)
On the left there is a node “make literal float” , You will need a variable there, thats the start time.
About setting Your time in the level, You could make an actor to CoundDown with Start time variable that is editable, than it would be possible by seting the time in that actor details. Probably the simplest one
Other better way, but not that simple would be calling CountDown in game instance blueprint
I believe that timeline is not a good way to create timers. You can have tons of timers and timeline nodes are evaluated each tick. So for example updating 100 timers 30+ times per second(3000 updates each second) isnt good for your performance. Timer events are really good for such purposes.Even 0.1s refresh rate can save you 2000 calls.
I just mean that timelines are made for a bit diffferent purposes. And about accuracy: by using a timer you can even create a floating refresh rate(when 90 secs remaining RR is 1update/sec, but when timer reaches 10s you can change RR to 10updates/sec etc). I believe its more flexible way for creating a timers. Also event dispatchers can be really useful when many BPs want to know about new second or about time expiration.
BUT timelines still can be used for some simple logic.