docs.unity3d.com
    Show / Hide Table of Contents

    Class NetworkTickSystem

    Provides discretized time. This is useful for games that require ticks happening at regular interval on the server and clients.

    Inheritance
    Object
    NetworkTickSystem
    Namespace: Unity.Netcode
    Syntax
    public class NetworkTickSystem

    Constructors

    NetworkTickSystem(UInt32, Double, Double)

    Creates a new instance of the NetworkTickSystem class.

    Declaration
    public NetworkTickSystem(uint tickRate, double localTimeSec, double serverTimeSec)
    Parameters
    Type Name Description
    UInt32 tickRate

    The tick rate

    Double localTimeSec

    The initial local time to start at.

    Double serverTimeSec

    The initial server time to start at.

    Fields

    NoTick

    Special value to indicate "No tick information"

    Declaration
    public const int NoTick = -2147483648
    Field Value
    Type Description
    Int32

    Properties

    LocalTime

    The current local time. This is the time at which predicted or client authoritative objects move. This value is accurate when called in Update or during the Tick event but does not work correctly for FixedUpdate.

    Declaration
    public NetworkTime LocalTime { get; }
    Property Value
    Type Description
    NetworkTime

    ServerTime

    The current server time. This value is mostly used for internal purposes and to interpolate state received from the server. This value is accurate when called in Update or during the Tick event but does not work correctly for FixedUpdate.

    Declaration
    public NetworkTime ServerTime { get; }
    Property Value
    Type Description
    NetworkTime

    TickRate

    The TickRate of the tick system. This is used to decide how often a fixed network tick is run.

    Declaration
    public uint TickRate { get; }
    Property Value
    Type Description
    UInt32

    Methods

    Reset(Double, Double)

    Resets the tick system to the given network time.

    Declaration
    public void Reset(double localTimeSec, double serverTimeSec)
    Parameters
    Type Name Description
    Double localTimeSec

    The local time in seconds.

    Double serverTimeSec

    The server time in seconds.

    UpdateTick(Double, Double)

    Called after advancing the time system to run ticks based on the difference in time.

    Declaration
    public void UpdateTick(double localTimeSec, double serverTimeSec)
    Parameters
    Type Name Description
    Double localTimeSec

    The local time in seconds

    Double serverTimeSec

    The server time in seconds

    Events

    Tick

    Gets invoked before every network tick.

    Declaration
    public event Action Tick
    Event Type
    Type Description
    Action
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023