Stopwatch help needed

Godot Version

Godot 4

Question

I want to add a StopWatch in an easy way in a 3d game. My game is about killing zombies, so to add the score, I want to add a stopwatch in it. How do I add stopwatch?

You can use Time.get_ticks_msec(). Remember the start time and subtract it from the current time.

1 Like

Another option is to create a variable called time or something similar. Then, during the _process function of a Label node, increase time by delta, make the variable time a string, take off some digits, and put that on the Label node. My code for this is this:

func _process(delta):
	updateTimer(delta)


func updateTimer(delta):
	if ingame:
		time += delta
	$Timer.text = String.num(time, 2)
	$Timer.show()

where $Timer is my Label node.