Wait Time
Part of the Game Rules section of Coddy's Godot journey. Lesson 3 of 29.
A timer's wait_time is how many seconds it counts. It is 1 unless you change it.
$Timer.wait_time = 3 # runs out every three seconds
$Timer.wait_time = 0.25 # four times a secondA smaller wait_time makes the timer run out more often. Set it in _ready(), before the timer starts. The timer reads it each time it starts counting.
Use it to set the pace of a game, like how often enemies appear.
Challenge
EasyMake the gate rise twice as fast.
- In
_ready(), set$Timer.wait_timeto0.5. - Keep the
actioncheck in_process()as it is.
Press Play, then E: the gate rises every half second. Then Check.
Try it yourself
extends Node2D
func _ready():
$Timer.timeout.connect(_on_timer_timeout)
func _process(delta):
if Input.is_action_just_pressed("action"):
$Timer.start()
func _on_timer_timeout():
$Gate.position.y -= 35
All lessons in Game Rules
Practice on your own: Godot playground