Menu
CoddyTech

The Timer Node

Part of the Game Rules section of Coddy's Godot journey. Lesson 1 of 29.

A Timer node counts down. When it reaches zero, it sends its timeout signal and starts again. Games use timers for bombs, spawns and blinking lights.

This lighthouse has a Timer that counts one second. It starts on its own when the game starts. Open the Scene tab to see it.

Connect timeout to a function, the same way you connected body_entered:

func _ready():
	$Timer.timeout.connect(_on_timer_timeout)

func _on_timer_timeout():
	print("One more second")

Now _on_timer_timeout() runs once every second.

challenge icon

Challenge

Easy

Make the lighthouse blink:

  1. In _ready(), connect $Timer.timeout to _on_timer_timeout.
  2. In _on_timer_timeout(), turn $Light off when it is on, and on when it is off.

Try it yourself

extends Node2D

func _ready():
	pass

func _on_timer_timeout():
	pass
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Game Rules

Practice on your own: Godot playground