Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

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.

Note: Timers are affected by Engine.time_scale, a higher scale means quicker timeouts, and vice versa.

Note: To create a one-shot timer without instantiating a node, use SceneTree.create_timer.

Tutorials

Properties

bool

autostart

false

bool

one_shot

false

bool

paused

TimerProcessCallback

process_callback

1

float

time_left

float

wait_time

1.0

Methods

bool

is_stopped ( ) const

void

start ( float time_sec=-1 )

void

stop ( )


Signals

timeout ( )

Emitted when the timer reaches 0.


Enumerations

enum TimerProcessCallback:

TimerProcessCallback TIMER_PROCESS_PHYSICS = 0

Update the timer during physics frames (see Node.NOTIFICATION_INTERNAL_PHYSICS_PROCESS).

TimerProcessCallback TIMER_PROCESS_IDLE = 1

Update the timer during process frames (see Node.NOTIFICATION_INTERNAL_PROCESS).


Property Descriptions

bool autostart = false

  • void set_autostart ( bool value )

  • bool has_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.


bool one_shot = false

  • void set_one_shot ( bool value )

  • bool is_one_shot ( )

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


bool paused

  • void set_paused ( bool value )

  • bool is_paused ( )

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


TimerProcessCallback process_callback = 1

Processing callback. See TimerProcessCallback.


float time_left

  • float get_time_left ( )

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

Note: This value is read-only and cannot be set. It is based on wait_time, which can be set using start.


float wait_time = 1.0

  • void set_wait_time ( float value )

  • float get_wait_time ( )

The wait time in seconds.

Note: Timers can only emit once per rendered frame at most (or once per physics frame if process_callback is TIMER_PROCESS_PHYSICS). This means very low wait times (lower than 0.05 seconds) will behave in significantly different ways depending on the rendered framerate. For very low wait times, it is recommended to use a process loop in a script instead of using a Timer node. Timers are affected by Engine.time_scale, a higher scale means quicker timeouts, and vice versa.


Method Descriptions

bool is_stopped ( ) const

Returns true if the timer is stopped.