How can I create a timer that counts up and stops when reaching end of level?

Hi all, does anyone know a way in blueprints to have a timer count up on screen during a level? Would like it to stop at the end trigger and move onto the next level.

Seen a few timer commands in blueprints but cant seem to get them working like this.

Thanks

Timers is only thing that you could use for that i think, what problem do you have with them?

Did you try to use Event Tick node? It will fire up every tick and also gives you the time passed since the last tick. You could then have two variables declared in blueprint:

  1. ElapsedTime - float
  2. CounterActive - boolean

On each Event Tick, you add the delta time to ElapsedTrime if CounterActive==true. When you hit the level end trigger, you set CounterActive to FALSE to stop the counting and possibly reset it to zero.

NOTE: As far as I know, the Timer in blueprint is used in a similar way as javascript setTimeout function. ie It will count down the set time and then fire a function/execute nodes. It does not mean it acts as a StopWatch. This is useful for doing some action after a delay (for example wait 10 seconds after player is dead and then show a Menu…)

Guess my problem is what timer to use and how to get it to show on the screen. Simple prototype could be for at start of level show timer that counts up. When player reaches trigger it end and completes the level. Do you know of any guides or tutorials I can follow?

Thanks for replying :slight_smile:

Thanks! Managed to get a timer working and the game to exit when you reach the trigger :slight_smile: Not perfect but its a great starting point! Now to figure out how to get it to save peoples times and compare them.

Thanks again!

Actually before updating the ElapsedTime with new value, you should check if CounterActive is true. Otherwise it will keep on counting even after the trigger.

PS: If the issue is solved, kindlymark mark it as ‘SOLVED’. (I think you should click the tick mark on the answer to do this). This will help other people with the same query.

Even though there is nothing hooked up to that branch, it is redundant. Which ever value feeds the branch could be plugged into the Set CounterActive so you have 2 less nodes. :slight_smile: Not critical

There is a function called Get Game Time in Seconds

5799-capture.png

And when you reach your trigger just save the last time value as the recorded time.

This is a great tutorial by Devin Sherry on how to make a timer.

The simplest form of timer you can create if you just want to be able to track what time has elapsed since the game started is this:

Unfortunately you can’t pause this timer so if you want to print a value of the time to a scoreboard when the player finishes the level then this won’t work. I’ve created a Timer Blueprint that I want to add to the Marketplace for free… we’ll see if they let it through. If not, I’ll make a tutorial video.