How to make a simple ingame timer that only counts the number of seconds passed?

I know there is an example game showing how to make an ingame timer that incorporates seconds, minutes, and hours elapsed, but I want to make a simpler ingame timer that only counts seconds elapsed. This is partly because I can’t make heads or tails of that example game’s coding, but also because I want to keep it simple.

In any case, how do I get this kind of timer to reset itself back to zero every time a player character gets to the next level?

3 Likes


Here you go. Then customize the label to how you want.
If you want something to happen by a certain time, then add a filter and change it to an “equal to or greater than” and do the rest.
Also here’s the timer settings:
Screenshot 2023-11-20 1.52.20 PM

1 Like

Thank you very much. I noticed that the timer example you’ve given automatically resets itself to zero when I transition from one level to another when I did some testing. Is there something in the code you’ve given that specifies this? I thought I would need something like a Mailbox block tied to the LoadLevel block used to change the level to get a message and then send it back to the Timer block in order to get the ingame timer to reset on a level change.

2 Likes

‘Numbers’ are not stored between levels. So when it changes between levels, it does not save. The ‘Global’ behavior on the other hand, does save between levels. Its nice to keep that in mind when programming games.

Everything is reset when the level changes.

1 Like

You could store a number in a global or a save behavior. I would show an example but I can’t right now.

@WYTam said that they wanted the timer to reset after each level, so this works without any extra code.

2 Likes

Okay, so if I want to make a timer that persists between levels, then I’ll need a Global variable block. That’s not something I know how to use yet.

Anyway, suppose I want to turn this simple timer that only counts the seconds elapsed into a countdown timer that tracks the number of seconds remaining, and also restarts the current level once time runs out. Would it work like the following?

Thanks everyone for your help so far.

2 Likes

yup, that code should work just fine.

2 Likes