How to make a clock counter?

I have a mini-game in which you must consider how long takes the user to pass through a level. I’ve seen a lot of tutorials on how to implement a countdown based on sth, but I want a simple digital clock that indicates the user how many minutes, seconds (and maybe milisecs) he is spending in his level.

I implemented a HUD like this:

And here you see my variables:

76469-sin+título.png

I didn’t find any idea on how to implement that time count… Any help will be really grateful!

1 Like

Hey Sonia,

There’s multiple ways you can do this.
One way to do it is, get event tick.

Plug in a float value + delta seconds(time since last frame), put that into a timespan variable and output the minutes,seconds and hours.

Here’s an image. Hope it helps!

2 Likes

One thing to consider is you’re not really wanting to measure how long the widget has been on the screen. You’re wanting to measure something like “how long has the player been active” or “how long have we been in this level.” Thinking of what exactly you are measuring should give you a good hint about the best place to put this logic. The UI element is just displaying that number, not calculating it.

My problem is more on where to put that even tick… Because my HUD blueprint (actually it is a Widget Blueprint), doesn’t have that event. Should it be in my First/Third person character blueprint?

could do in character and expose that variable to your widget bp

Ok, it works perfectly! Now I’m trying to bind it to my timer in my HUD… -_- I’m a bit newbie sorry…

Oh, it can’t be done in my character, as the character can die, so I used the level blueprint to print the string as I want to measure “how long the user is in a level”. Do you think it is a correct place¿

Either in the level blueprint or if you use a game mode/game state blueprint you can have the counter going independent of the player. You can find more information on these here:

https://docs.unrealengine.com/latest/INT/Gameplay/index.html

Thank you