Simple timer

I can’t find an answer to my question anywhere, so I’ll ask here.
I have a game where the character must go from the beginning to the end of the entire map. At this time, there should be a timer, it shows how much time the player spent on passing it.
The bottom line is that if my character dies, the timer should continue. Approximately as shown in the picture.

What exactly is the issue?
If your game is single player, then just put a timer in the GameMode, start it at begin play or when you want it, stop and pause it when you want it and that’s it. It’s not affected by the player dying … unless you’re loading the map again, in that case, save the time, for example in the gameinstance, and then added it to the current time.


I was going to say the same. I’m confused, because if you’re just starting out, everything seems difficult, but if you’re making a game, a timer is one of the easiest things to create.

Not sure what’s going on here.

It’s like baking a cake, but not knowing how to turn the oven on.

Maybe I/We are not understanding this person.

Excuse me sir, I’m begginer, maybe there’s a tutorial like this on tutorial sites?
Or could you show how to do it yourself?

We still need to know more information.
When the player dies, do you reload the level or respawn the player or reset the player?

Anyway, we start with some basic timer setup in the gamemode, that will count every second:

1 Like

after the character falls, the inscription “you died” appears and my character respawns at the position where he started his journey, while the level continues, it does not restart

I take an example from this game:
YouTube Video Game (from 1:34)

Then is as it’s.
You have your widget BP to which you’re going to send the current seconds:

And in your gameplay, you set your widget and your timer at the begin play, send the seconds to the widget at every second and when the player completes the level, stop the timer.


Pardon my ignorance, sir, but did you add anything to the Event Graph in the widget itself

Yes. I created the function SetTimer, that takes the total seconds, calculates the minutes (=total seconds / 60) and seconds (=total seconds % 60) and updates the corresponding text widget.

This is my BP Game Mod:

This is my Set Time

But he dont work :frowning:

At begin play you are invoking a “Start Timer” function instead of “Start Time” custom event. What is “Start Timer” function doing? Does this function invokes “Start Time”?

I didn’t fully understand your question, but I followed your example. And at the end you have “Start Timer”

Also I get an error in “Custom Event” when I name it “StartTimer”.

When I give it the name “StartTime” there is no error

That’s because you already have a “StartTimer” function in the gamemode.

it is empty, apparently I created it by accident

Delete that function and correct the gamemode. Is it working now?

Hello, unfortunately it did not work, I will try to achieve this process so that the timer works.

Finally, I did it, I just redid everything on a new one and it worked !!!
Thank you very much, you are an expert in your field!

How can i add hour value to make it work

I also added a variable to each. And it works too.

I did this but don’t know if it will work, most likely I’ll have to wait 1 hour to find out :smile:
Also, I added another (/) to the “hours” value:

First, there is no need to wait. To quickly test, you can just set the initial value of the timer to some value other than 0:

Second, to calculate the hours, minutes and seconds:


Thanks, your advice helped me a lot!

1 Like