Class NetworkTimeSystem
NetworkTimeSystem is a standalone system which can be used to run a network time simulation. The network time system maintains both a local and a server time. The local time is based on
#
InheritanceSystem.Object
NetworkTimeSystem
#
Inherited MembersSystem.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
#
Namespace: Unity.Netcode#
Assembly: MLAPI.dll#
Syntax#
Constructors#
NetworkTimeSystem(Double, Double, Double, Double)The constructor class for NetworkTickSystem
#
Declaration#
ParametersType | Name | Description |
---|---|---|
System.Double | localBufferSec | The amount of time, in seconds, the server should buffer incoming client messages. |
System.Double | serverBufferSec | The amount of the time in seconds the client should buffer incoming messages from the server. |
System.Double | hardResetThresholdSec | The threshold, in seconds, used to force a hard catchup of network time. |
System.Double | adjustmentRatio | The ratio at which the NetworkTimeSystem speeds up or slows down time. |
#
Properties#
AdjustmentRatioGets or sets the ratio at which the NetworkTimeSystem speeds up or slows down time.
#
Declaration#
Property ValueType | Description |
---|---|
System.Double |
#
HardResetThresholdSecGets or sets a threshold in seconds used to force a hard catchup of network time.
#
Declaration#
Property ValueType | Description |
---|---|
System.Double |
#
LocalBufferSecGets or sets the amount of time in seconds the server should buffer incoming client messages. This increases the difference between local and server time so that messages arrive earlier on the server.
#
Declaration#
Property ValueType | Description |
---|---|
System.Double |
#
LocalTimeThe current local time with the local time offset applied
#
Declaration#
Property ValueType | Description |
---|---|
System.Double |
#
ServerBufferSecGets or sets the amount of the time in seconds the client should buffer incoming messages from the server. This increases server time. A higher value increases latency but makes the game look more smooth in bad networking conditions. This value must be higher than the tick length client side.
#
Declaration#
Property ValueType | Description |
---|---|
System.Double |
#
ServerTimeThe current server time with the server time offset applied
#
Declaration#
Property ValueType | Description |
---|---|
System.Double |
#
Methods#
Advance(Double)Advances the time system by a certain amount of time. Should be called once per frame with Time.deltaTime or similar.
#
Declaration#
ParametersType | Name | Description |
---|---|---|
System.Double | deltaTimeSec | The amount of time to advance. The delta time which passed since Advance was last called. |
#
ReturnsType | Description |
---|---|
System.Boolean |
#
Reset(Double, Double)Resets the time system to a time based on the given network parameters.
#
Declaration#
ParametersType | Name | Description |
---|---|---|
System.Double | serverTimeSec | The most recent server time value received in seconds. |
System.Double | rttSec | The current RTT in seconds. Can be an averaged or a raw value. |
#
ServerTimeSystem()Creates a new instance of the NetworkTimeSystem class for a server instance. The server will not apply any buffer values which ensures that local time equals server time.
#
Declaration#
ReturnsType | Description |
---|---|
NetworkTimeSystem | The instance. |
#
Sync(Double, Double)Synchronizes the time system with up-to-date network statistics but does not change any time values or advance the time.
#
Declaration#
ParametersType | Name | Description |
---|---|---|
System.Double | serverTimeSec | The most recent server time value received in seconds. |
System.Double | rttSec | The current RTT in seconds. Can be an averaged or a raw value. |