i have a relatively easy question, i want to make a timer into my game, or specifically a label that displays how much time has elapsed, but for some reason i cant really find anything related online, if anyone knows, thank you!
any help is appreciated!
You could use the _update method of a Label to accumulate delta (which is a float value that represents seconds between frames). Then, you can use that variable to create the text to be shown on the label. That depends on what you would like to show (seconds, minutes, etc)
extends Label
var time
func _process(delta):
time += delta
text = str(int(time)) # Show just the seconds.
You can use set_process_enabled to start/pause the timer.
You can do this with a regular label, and feed it with Time.get_ticks_msec(). That’ll just be a millisecond count, so you probably want to do some div/mod math to turn it into seconds, minutes and hours.
Sorry for reviving this thread, but I just recently learned that using delta for measuring real world time might not be the best. See the notes for _process and _physics_process.