Skip to main content

Unity.Netcode.NetworkTime

A struct to represent a point of time in a networked game. Time is stored as a combination of amount of passed ticks + a duration offset. This struct is meant to replace the Unity Time API for multiplayer gameplay.

Inherited Members#

ValueType.Equals(Object)

ValueType.GetHashCode()

ValueType.ToString()

Object.Equals(Object, Object)

Object.GetType()

Object.ReferenceEquals(Object, Object)

Namespace: System.Dynamic.ExpandoObject#
Assembly: MLAPI.dll#
Syntax#
public struct NetworkTime

NetworkTime(UInt32)#

Creates a new instance of the NetworkTime struct.

Declaration#

public NetworkTime(uint tickRate)

Parameters#

TypeNameDescription
System.UInt32tickRateThe tickrate.

NetworkTime(UInt32, Double)#

Creates a new instance of the NetworkTime struct.

Declaration#

public NetworkTime(uint tickRate, double timeSec)

Parameters#

TypeNameDescription
System.UInt32tickRateThe tickrate.
System.DoubletimeSecThe time value as a float.

NetworkTime(UInt32, Int32, Double)#

Creates a new instance of the NetworkTime struct.

Declaration#

public NetworkTime(uint tickRate, int tick, double tickOffset = 0)

Parameters#

TypeNameDescription
System.UInt32tickRateThe tickrate.
System.Int32tickThe time will be created with a value where this many tick have already passed.
System.DoubletickOffsetCan be used to create a NetworkTime with a non fixed time value by adding an offset to the given tick value.

#

FixedDeltaTime#

Gets the fixed delta time. This value is based on the TickRate and stays constant. Similar to There is no equivalent to

Declaration#

public readonly float FixedDeltaTime { get; }

Property Value#

TypeDescription
System.Single

FixedTime#

Gets he current fixed network time. This is the time value of the last network tick. Similar to

Declaration#

public readonly double FixedTime { get; }

Property Value#

TypeDescription
System.Double

Tick#

Gets the amount of network ticks which have passed until reaching the current time value.

Declaration#

public readonly int Tick { get; }

Property Value#

TypeDescription
System.Int32

TickOffset#

Gets the amount of time which has passed since the last network tick.

Declaration#

public readonly double TickOffset { get; }

Property Value#

TypeDescription
System.Double

TickRate#

Gets the tickrate of the system of this NetworkTime. Ticks per second.

Declaration#

public readonly uint TickRate { get; }

Property Value#

TypeDescription
System.UInt32

Time#

Gets the current time. This is a non fixed time value and similar to

Declaration#

public readonly double Time { get; }

Property Value#

TypeDescription
System.Double

TimeAsFloat#

Gets the current time as a float.

Declaration#

public readonly float TimeAsFloat { get; }

Property Value#

TypeDescription
System.Single

#

TimeTicksAgo(Int32)#

Declaration#

public NetworkTime TimeTicksAgo(int ticks)

Parameters#

TypeNameDescription
System.Int32ticks

Returns#

TypeDescription
NetworkTime

ToFixedTime()#

Converts the network time into a fixed time value.

Declaration#

public NetworkTime ToFixedTime()

Returns#

TypeDescription
NetworkTimeA NetworkTime where Time is the FixedTime value of this instance.

#

Addition(NetworkTime, Double)#

Declaration#

public static NetworkTime operator +(NetworkTime a, double b)

Parameters#

TypeNameDescription
NetworkTimea
System.Doubleb

Returns#

TypeDescription
NetworkTime

Addition(NetworkTime, NetworkTime)#

Declaration#

public static NetworkTime operator +(NetworkTime a, NetworkTime b)

Parameters#

TypeNameDescription
NetworkTimea
NetworkTimeb

Returns#

TypeDescription
NetworkTime

Subtraction(NetworkTime, Double)#

Declaration#

public static NetworkTime operator -(NetworkTime a, double b)

Parameters#

TypeNameDescription
NetworkTimea
System.Doubleb

Returns#

TypeDescription
NetworkTime

Subtraction(NetworkTime, NetworkTime)#

Declaration#

public static NetworkTime operator -(NetworkTime a, NetworkTime b)

Parameters#

TypeNameDescription
NetworkTimea
NetworkTimeb

Returns#

TypeDescription
NetworkTime