Timer

Inherits: Node < Object

A countdown timer.

Description

Counts down a specified interval and emits a signal on reaching 0. Can be set to repeat or “one-shot” mode.

Methods

boolis_stopped ( ) const
voidstart ( float time_sec=-1 )
voidstop ( )

Signals

  • timeout ( )

Emitted when the timer reaches 0.

Enumerations

enum TimerProcessMode:

  • TIMER_PROCESS_PHYSICS = 0 — Update the timer during the physics step at each frame (fixed framerate processing).
  • TIMER_PROCESS_IDLE = 1 — Update the timer during the idle time at each frame.

Property Descriptions

Defaultfalse
Setterset_autostart(value)
Getterhas_autostart()

If true, the timer will automatically start when entering the scene tree.

Note: This property is automatically set to false after the timer enters the scene tree and starts.


Defaultfalse
Setterset_one_shot(value)
Getteris_one_shot()

If true, the timer will stop when reaching 0. If false, it will restart.


Setterset_paused(value)
Getteris_paused()

If true, the timer is paused and will not process until it is unpaused again, even if start is called.


Default1
Setterset_timer_process_mode(value)
Getterget_timer_process_mode()

Processing mode. See TimerProcessMode.


Getterget_time_left()

The timer’s remaining time in seconds. Returns 0 if the timer is inactive.

Note: You cannot set this value. To change the timer’s remaining time, use start.


Default1.0
Setterset_wait_time(value)
Getterget_wait_time()

Wait time in seconds.

Method Descriptions

  • bool is_stopped ( ) const

Returns true if the timer is stopped.


  • void start ( float time_sec=-1 )

Starts the timer. Sets wait_time to time_sec if time_sec > 0. This also resets the remaining time to wait_time.

Note: this method will not resume a paused timer. See paused.


  • void stop ( )

Stops the timer.

Doc ID missing

Disclaimer: This page has been automaticaly and directly extracted from the official Godot Docs website, the 1970-01-01 at 00:00:00. It’s the English Stable version because it’s what most Godot users should use. The Copyright owners are Juan Linietsky, Ariel Manzur and the Godot community. CC-BY 3.0. Thanks for your patience and generosity.