docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class Clock

    Provides a unified simulation time source for Simulation Pro.

    Inheritance
    object
    Clock
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.SimulationPro.Foundation
    Assembly: Unity.SimulationPro.Foundation.dll
    Syntax
    public static class Clock
    Remarks

    The active clock mode is determined automatically at startup based on whether a TimeStepApplier component is present in the scene:

    • UnityUnscaled (default) — uses Time.timeAsDouble.
    • FoundationClock — uses the TimeStepApplier accumulator.
    • ExternalClock — time is pushed from an external source (distributed rendering).
    The mode resets whenever the active scene changes.

    Properties

    DeltaTimeInSeconds

    Gets the elapsed time in seconds for the current frame's delta, according to the active clock mode.

    Declaration
    public static float DeltaTimeInSeconds { get; }
    Property Value
    Type Description
    float
    Remarks

    Precision may be lower than Now because Unity does not expose a deltaTimeAsDouble API.

    Now

    Time recorded, in seconds, at the beginning of the current Update/FixedUpdate TODO: Now must always report the most recent FixedUpdate, even when called from Update. Physics never updates in Update, so the simulation is only tracking FixedUpdates

    Declaration
    public static double Now { get; }
    Property Value
    Type Description
    double

    NowTimeInSeconds

    Gets the current simulation time in seconds. Use Now instead.

    Declaration
    [Obsolete("Use Clock.Now instead.")]
    public static double NowTimeInSeconds { get; }
    Property Value
    Type Description
    double

    TimeAsMessage

    Gets the current simulation time as a ROS builtin_interfaces/Time message. Use ClockHelpers.Now instead.

    Declaration
    [Obsolete("Use ClockHelpers.Now instead.")]
    public static TimeMsg TimeAsMessage { get; }
    Property Value
    Type Description
    TimeMsg

    deltaTime

    Gets the elapsed time in seconds for the current frame's delta. Equivalent to DeltaTimeInSeconds.

    Declaration
    public static float deltaTime { get; }
    Property Value
    Type Description
    float

    Methods

    EnsureSimulatedTime()

    Ensures that a TimeStepApplier is present and activates FoundationClock mode.

    Declaration
    public static void EnsureSimulatedTime()
    Remarks

    Call this once during scene setup when deterministic stepped simulation time is required. If no TimeStepApplier exists in the scene, one is created automatically.

    SetExternalTime(double, double, float)

    Sets the current time values when the clock is in ExternalClock mode.

    Declaration
    public static void SetExternalTime(double timeAsDouble, double fixedTimeAsDouble, float unscaledDeltaTime)
    Parameters
    Type Name Description
    double timeAsDouble

    The frame start time in seconds from the external source.

    double fixedTimeAsDouble

    The fixed-update start time in seconds from the external source.

    float unscaledDeltaTime

    The unscaled delta time in seconds for the current frame.

    Remarks

    This method is called internally by the distributed rendering integration and should not normally be called by user code.

    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)