A countdown timer.
    public class Timer : Node

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

Inheritance Chain

Constructors

    public Timer()

Signals

    "timeout" ()

Emitted when the timer reaches 0.

Properties

    public bool Autostart { get; set; }

If true, the timer will automatically start when entering the scene tree. Default value: false.

    public bool OneShot { get; set; }

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

    public bool Paused { get; set; }

If true, the timer is paused and will not process until it is unpaused again, even if Start(float) is called.

    public TimerProcessMode ProcessMode { get; set; }

Processing mode. See TimerProcessMode.

    public float TimeLeft { get; }

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 WaitTime.

    public float WaitTime { get; set; }

Wait time in seconds.

Methods

    public float GetTimeLeft()

Getter for TimeLeft

    public TimerProcessMode GetTimerProcessMode()

Getter for ProcessMode

    public float GetWaitTime()

Getter for WaitTime

    public bool HasAutostart()

Getter for Autostart

    public bool IsOneShot()

Getter for OneShot

    public bool IsPaused()

Getter for Paused

    public bool IsStopped()

Returns true if the timer is stopped.

    public void SetAutostart(bool enable)

Setter for Autostart

    public void SetOneShot(bool enable)

Setter for OneShot

    public void SetPaused(bool paused)

Setter for Paused

    public void SetTimerProcessMode(TimerProcessMode mode)

Setter for ProcessMode

    public void SetWaitTime(float timeSec)

Setter for WaitTime

    public void Start(float timeSec = -1f)

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

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

    public void Stop()

Stops the timer.

Inner Types

TimerProcessMode

Name Value Description
Physics 0 Update the timer during the physics step at each frame (fixed framerate processing).
Idle 1 Update the timer during the idle time at each frame.
Tags: