Struct 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 MembersSystem.ValueType.Equals(System.Object)
System.ValueType.GetHashCode()
System.ValueType.ToString()
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.ReferenceEquals(System.Object, System.Object)
#
Namespace: Unity.Netcode#
Assembly: MLAPI.dll#
Syntax#
Constructors#
NetworkTime(UInt32)Creates a new instance of the NetworkTime struct.
#
Declaration#
ParametersType | Name | Description |
---|---|---|
System.UInt32 | tickRate | The tickrate. |
#
NetworkTime(UInt32, Double)Creates a new instance of the NetworkTime struct.
#
Declaration#
ParametersType | Name | Description |
---|---|---|
System.UInt32 | tickRate | The tickrate. |
System.Double | timeSec | The time value as a float. |
#
NetworkTime(UInt32, Int32, Double)Creates a new instance of the NetworkTime struct.
#
Declaration#
ParametersType | Name | Description |
---|---|---|
System.UInt32 | tickRate | The tickrate. |
System.Int32 | tick | The time will be created with a value where this many tick have already passed. |
System.Double | tickOffset | Can be used to create a NetworkTime with a non fixed time value by adding an offset to the given tick value. |
#
Properties#
FixedDeltaTimeGets the fixed delta time. This value is based on the TickRate and stays constant. Similar to There is no equivalent to
#
Declaration#
Property ValueType | Description |
---|---|
System.Single |
#
FixedTimeGets he current fixed network time. This is the time value of the last network tick. Similar to
#
Declaration#
Property ValueType | Description |
---|---|
System.Double |
#
TickGets the amount of network ticks which have passed until reaching the current time value.
#
Declaration#
Property ValueType | Description |
---|---|
System.Int32 |
#
TickOffsetGets the amount of time which has passed since the last network tick.
#
Declaration#
Property ValueType | Description |
---|---|
System.Double |
#
TickRateGets the tickrate of the system of this NetworkTime. Ticks per second.
#
Declaration#
Property ValueType | Description |
---|---|
System.UInt32 |
#
TimeGets the current time. This is a non fixed time value and similar to
#
Declaration#
Property ValueType | Description |
---|---|
System.Double |
#
TimeAsFloatGets the current time as a float.
#
Declaration#
Property ValueType | Description |
---|---|
System.Single |
#
Methods#
TimeTicksAgo(Int32)Returns the time a number of ticks in the past.
#
Declaration#
ParametersType | Name | Description |
---|---|---|
System.Int32 | ticks | The number of ticks ago we're querying the time |
#
ReturnsType | Description |
---|---|
NetworkTime |
#
ToFixedTime()Converts the network time into a fixed time value.
#
Declaration#
ReturnsType | Description |
---|---|
NetworkTime | A NetworkTime where Time is the FixedTime value of this instance. |
#
Operators#
Addition(NetworkTime, Double)Computes the time a number of seconds later
#
Declaration#
ParametersType | Name | Description |
---|---|---|
NetworkTime | a | The start time |
System.Double | b | The number of seconds to add |
#
ReturnsType | Description |
---|---|
NetworkTime | The resulting time |
#
Addition(NetworkTime, NetworkTime)Computes the sum of two times
#
Declaration#
ParametersType | Name | Description |
---|---|---|
NetworkTime | a | First time |
NetworkTime | b | Second time |
#
ReturnsType | Description |
---|---|
NetworkTime | The sum of the two times passed in |
#
Subtraction(NetworkTime, Double)Computes the time a number of seconds before
#
Declaration#
ParametersType | Name | Description |
---|---|---|
NetworkTime | a | The start time |
System.Double | b | The number of seconds to remove |
#
ReturnsType | Description |
---|---|
NetworkTime | The resulting time |
#
Subtraction(NetworkTime, NetworkTime)Computes the time difference between two ticks
#
Declaration#
ParametersType | Name | Description |
---|---|---|
NetworkTime | a | End time |
NetworkTime | b | Start time |
#
ReturnsType | Description |
---|---|
NetworkTime | The time difference between start and end |