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.

    public bool OneShot { get; set; }

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

    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

    [Obsolete("GetTimeLeft is deprecated. Use the TimeLeft property instead.")]
    public float GetTimeLeft()

Getter for TimeLeft

    [Obsolete("GetTimerProcessMode is deprecated. Use the ProcessMode property instead.")]
    public TimerProcessMode GetTimerProcessMode()

Getter for ProcessMode

    [Obsolete("GetWaitTime is deprecated. Use the WaitTime property instead.")]
    public float GetWaitTime()

Getter for WaitTime

    [Obsolete("HasAutostart is deprecated. Use the Autostart property instead.")]
    public bool HasAutostart()

Getter for Autostart

    [Obsolete("IsOneShot is deprecated. Use the OneShot property instead.")]
    public bool IsOneShot()

Getter for OneShot

    [Obsolete("IsPaused is deprecated. Use the Paused property instead.")]
    public bool IsPaused()

Getter for Paused

    public bool IsStopped()

Returns true if the timer is stopped.

    [Obsolete("SetAutostart is deprecated. Use the Autostart property instead.")]
    public void SetAutostart(bool enable)

Setter for Autostart

    [Obsolete("SetOneShot is deprecated. Use the OneShot property instead.")]
    public void SetOneShot(bool enable)

Setter for OneShot

    [Obsolete("SetPaused is deprecated. Use the Paused property instead.")]
    public void SetPaused(bool paused)

Setter for Paused

    [Obsolete("SetTimerProcessMode is deprecated. Use the ProcessMode property instead.")]
    public void SetTimerProcessMode(TimerProcessMode mode)

Setter for ProcessMode

    [Obsolete("SetWaitTime is deprecated. Use the WaitTime property instead.")]
    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: