There are a number of ways to do this. Here's the basics with a Timer
.
- Add a
Timer
to a sample scene
- In the inspector, set the timer's
wait_time = 1
, autostart = true
, and one_shot = false
- Connect its
timeout
signal to a script containing something like:
.
var score = 0
func _on_Timer_timeout() -> void:
score += 1
print(score)
So, each time the timer "times out" (after 1 second here), it'll call the _on_Timer_timeout()
function, which will increment the score. Once that happens, the Timer
will automaticlally reset to 1 second and being counting down again, repeating the process.