Speedrun Timer

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By djmick

How would I make a speedrun timer that starts counting from the beginning of the first scene (level), and ends at the end of the last scene?

Create a timer in a singleton
the docs will show you how singletons work. As well as show you how to use them if you are unfamiliar.
Singletons (Autoload) — Godot Engine (stable) documentation in English

Singletons will keep your data from scene to scene. In this case it will keep your clock running til you tell it when you want it to stop.

RakuNana | 2020-08-06 00:33

:bust_in_silhouette: Reply From: sarthakroy

You can create a timer as a Singleton by -

Then you can you can start it and it will take account of the time from scene to scene and at the end , you and put some interaction due to which the Timer stops.

Thanks that is working, but I can’t get my timer to count by one every second. Even if I put a yield, it still counts by one every frame.

djmick | 2020-08-06 23:27

Oh yes ! That is one of the problems . I used to solve this problem (in general cases) by -

Suppose you have 6 Frames per second (for example) :
Then time will be 6 but you want it to be one .
In general cases , I used to divide time by 6 to get it in seconds.
This is the main logic .

Visit this for complete code :-

https://gdscript.com/godot-timing-tutorial

sarthakroy | 2020-08-07 02:49

Oh, thank you! That actually worked perfectly!

djmick | 2020-08-08 19:51

You are welcome !

sarthakroy | 2020-08-09 04:10