Struct ClientTickRate
Create a ClientTickRate singleton in the client world (either at runtime or by loading it from sub-scene) to configure all the network time synchronization, interpolation delay, prediction batching and other setting for the client. See the individual fields for more information about the individual properties.
Implements
Inherited Members
Namespace: Unity.NetCode
Assembly: Unity.NetCode.dll
Syntax
[Serializable]
public struct ClientTickRate : IComponentData, IQueryTypeParameter
Fields
CommandAgeCorrectionFraction
The percentage of the error in the predicted server tick that can be corrected each frame. Used to control the client deltaTime scaling, used to slow-down/speed-up the server tick estimate. Must be in (0, 1) range.
________ Max
/
/
Min ______/__________
CommandAge
DefaultValue: 10% of the error. The two major causes affecting the command age are: - Network condition (Latency and Jitter) - Server performance (running below the target frame rate)
Small time scale values allow for smooth adjustments of the prediction tick but slower reaction to changes in both network and server frame rate. By using larger values, is faster to recovery to desync situation (caused by bad network and condition or/and slow server performance) but the predicted ticks delta are larger. Good ranges: [0.075 - 0.2]
Declaration
[Tooltip("The percentage of the error in the predicted server tick that can be corrected each frame. Used to control the client deltaTime scaling, used to slow-down/speed-up the server tick estimate.\n\nDefaults to 10% of the error. Recommended range is [0.075 - 0.2].\n\n - Small time scale values allow for smooth adjustments of the prediction tick, but slower reaction to changes in both network and server frame rate.\n - Larger values causes recovery to be faster in desync situations, but the predicted ticks delta are larger.")]
[Range(0, 1)]
public float CommandAgeCorrectionFraction
Field Value
Type | Description |
---|---|
float |
InterpolationDelayCorrectionFraction
The percentage of the error in the interpolation delay that can be corrected in one frame. Used to control InterpolationTickTimeScale. Must be in range (0, 1).
________ Max
/
/
Min _____/____________
InterpolationDelayDelta
DefaultValue: 10% of the delta in between the current and next desired interpolation tick. Good ranges: [0.075 - 0.2]
Declaration
[Tooltip("The percentage of the error in the interpolation delay that can be corrected in one frame. Used to control InterpolationTickTimeScale.\n\nRecommended range is [0.075 - 0.2].")]
[Range(0, 1)]
public float InterpolationDelayCorrectionFraction
Field Value
Type | Description |
---|---|
float |
InterpolationDelayJitterScale
Multiplier used to compensate received snapshot rate jitter when calculating the Interpolation Delay. Default Value: 1.25.
Declaration
[Tooltip("Multiplier used to compensate received snapshot rate jitter when calculating the Interpolation Delay.\n\nDefaults to 1.25.")]
[Min(0.001)]
public float InterpolationDelayJitterScale
Field Value
Type | Description |
---|---|
float |
InterpolationDelayMaxDeltaTicksFraction
Used to limit the maximum InterpolationDelay changes in one frame, as percentage of the frame deltaTicks. Default value: 10% of the frame delta ticks. Smaller values will result in slow adaptation to the network state (loss and jitter) but would result in smooth delay changes. Larger values would make the InterpolationDelay change quickly adapt but may cause sudden jump in the interpolated values. Good ranges: [0.10 - 0.3]
Declaration
[Tooltip("Used to limit the maximum InterpolationDelay changes in one frame, as percentage of the frame deltaTicks.\n\nDefaults to 10% of the frame delta ticks. Recommended range is [0.10 - 0.3].\n\n - Smaller values will result in slow adaptation to the network state (loss and jitter) but would result in smooth delay changes.\n - Larger values would make the InterpolationDelay change quickly adapt but may cause sudden jump in the interpolated values.")]
[Range(0.01, 0.5)]
public float InterpolationDelayMaxDeltaTicksFraction
Field Value
Type | Description |
---|---|
float |
InterpolationTimeMS
The time in ms to use as an interpolation buffer for interpolated ghosts, this will take precedence and override the interpolation time in ticks if specified.
Declaration
[Tooltip("If not zero, denotes the number of milliseconds to use as an interpolation buffer for interpolated ghosts.\n\nDefaults to 0 (OFF).\n\n<b>Warning: Is used instead of InterpolationTimeNetTicks, if set.</b>")]
[Min(0)]
public uint InterpolationTimeMS
Field Value
Type | Description |
---|---|
uint |
InterpolationTimeNetTicks
The number of network ticks to use as an interpolation buffer for interpolated ghosts.
Declaration
[Tooltip("If not zero, denotes the number of network ticks to use as an interpolation buffer for interpolated ghosts.\n\nDefaults to 2.\n\n<b>Warning: Ignored when InterpolationTimeMS is set.</b>")]
[Min(0)]
public uint InterpolationTimeNetTicks
Field Value
Type | Description |
---|---|
uint |
InterpolationTimeScaleMax
The maximum value for the InterpolateTimeScale. Must be greater that 1.0. Default: 1.1.
Declaration
[Tooltip("The maximum value for the InterpolateTimeScale.\n\nDefaults to 1.1.")]
[Min(1)]
public float InterpolationTimeScaleMax
Field Value
Type | Description |
---|---|
float |
InterpolationTimeScaleMin
The minimum value for the InterpolateTimeScale. Must be in range (0, 1) Default: 0.85.
Declaration
[Tooltip("The minimum value for the InterpolateTimeScale.\n\nDefaults to 0.85.")]
[Range(0, 1)]
public float InterpolationTimeScaleMin
Field Value
Type | Description |
---|---|
float |
MaxExtrapolationTimeSimTicks
The maximum time (in simulation ticks) which the client can extrapolate ahead, when data is missing.
Declaration
[Tooltip("The maximum time (in simulation ticks) which the client can extrapolate ahead, when data is missing.\n\nDefaults to 20.")]
[Min(0)]
public uint MaxExtrapolationTimeSimTicks
Field Value
Type | Description |
---|---|
uint |
MaxPredictAheadTimeMS
This is the maximum accepted ping. RTT will be clamped to this value when calculating the server tick on the client, which means if ping is higher than this, the server will get old commands. Increasing this makes the client able to deal with higher ping, but higher-ping clients will then need to run more prediction steps, which incurs more CPU time.
Declaration
[Tooltip("This is the maximum accepted ping. RTT will be clamped to this value when calculating the server tick on the client, which means if ping is higher than this, the server will get old commands.\n\nIncreasing this makes the client able to deal with higher ping, but higher-ping clients will then need to run more prediction steps, which incurs more CPU time.")]
[Range(0, 500)]
public uint MaxPredictAheadTimeMS
Field Value
Type | Description |
---|---|
uint |
MaxPredictionStepBatchSizeFirstTimeTick
The client can batch simulation steps in the prediction loop. This setting controls how many simulation steps the simulation can batch, for ticks which are being predicted for the first time. Setting this to a value larger than 1 will save performance, but the gameplay systems needs to be adapted.
Declaration
[Tooltip("The client can batch simulation steps in the prediction loop. This setting controls how many simulation steps the simulation can batch, <b>for ticks which are being predicted for the first time</b>.\n\nWhen 0, defaults to 1 at runtime.\n\nSetting this to a value larger than 1 will save performance at the cost of simulation accuracy. Gameplay systems needs to be adapted.")]
[Range(0, 16)]
public int MaxPredictionStepBatchSizeFirstTimeTick
Field Value
Type | Description |
---|---|
int |
MaxPredictionStepBatchSizeRepeatedTick
The client can batch simulation steps in the prediction loop. This setting controls how many simulation steps the simulation can batch, for ticks which have previously been predicted. Setting this to a value larger than 1 will save performance, but the gameplay systems must account for it.
Declaration
[Tooltip("The client can batch simulation steps in the prediction loop. This setting controls how many simulation steps the simulation can batch, <b>for ticks which have previously been predicted</b>.\n\nWhen 0, defaults to 1 at runtime.\n\nSetting this to a value larger than 1 will save performance at the cost of simulation accuracy. Gameplay systems need to account for it.")]
[Range(0, 16)]
public int MaxPredictionStepBatchSizeRepeatedTick
Field Value
Type | Description |
---|---|
int |
NumAdditionalCommandsToSend
The CommandSendSystem
will send TargetCommandSlack + NumAdditionalCommandsToSend
commands in each input packet (default of 2 and 2, thus 4), as a packet loss recovery mechanism (hard max: 32, see k_MaxInputBufferSendSize).
This option defines how many additional packets to send (on top of TargetCommandSlack
).
Min value is 1, as sending zero additional inputs can cause input loss, even on connections with zero packet loss.
Default value is 2.
Higher values incur more server ingress bandwidth consumption, but can be useful when dealing with unstable connections.
However, you may just be re-sending commands that are already too old to be used.
Declaration
[Tooltip("The `CommandSendSystem` will send `TargetCommandSlack` + `NumAdditionalCommandsToSend` commands in each input packet (default of 2 and 2, thus 4), as a packet loss recovery mechanism.\n\nThis option defines how many additional packets to send (on top of `TargetCommandSlack`).\n\nMin value is 1, default value is 2.\n\nHigher values incur more server ingress bandwidth consumption, but can be useful when dealing with unstable connections.\n\nDebug command arrival rate (and statistics) via the Packet Dump Utility and/or the `NetworkSnapshotAck.CommandArrivalStats`.")]
[Range(1, 32)]
public uint NumAdditionalCommandsToSend
Field Value
Type | Description |
---|---|
uint |
Remarks
Debug command arrival rate (and statistics) via the Packet Dump Utility and/or the CommandArrivalStatistics.
PredictionTimeScaleMax
PredictionTick time scale max value, max be greater then 1.0f. Default: 1.1f Note: it is not mandatory to have the min-max symmetric. Good Range: (1.05 - 1.2)
Declaration
[Tooltip("PredictionTick time scale max value.\n\nDefaults to 1.1. Recommended range is (1.05 - 1.2).\n\nNote: It is not mandatory to have the min and max values symmetric.")]
[Range(1, 2)]
public float PredictionTimeScaleMax
Field Value
Type | Description |
---|---|
float |
PredictionTimeScaleMin
PredictionTick time scale min value, max be less then 1.0f. Default: 0.9f. Note: it is not mandatory to have the min-max symmetric. Good Range: (0.8 - 0.95)
Declaration
[Tooltip("The PredictionTick time scale min value.\n\nDefaults to 0.9. Recommended range is (0.8 - 0.95).\n\nNote: It is not mandatory to have the min and max values symmetric.")]
[Range(0, 1)]
public float PredictionTimeScaleMin
Field Value
Type | Description |
---|---|
float |
TargetCommandSlack
Specifies the number of simulation ticks that the client tries to stay ahead of the server, to try to make sure the commands are received by the server before they are actually consumed.
Declaration
[Tooltip("Specifies the number of simulation ticks that the client tries to stay ahead of the server, to try to make sure the commands are received by the server before they are actually consumed.\n\nDefaults to 2.\n\nHigher values increase command arrival reliability, at the cost of a longer client prediction window (which can itself degrade gameplay performance). This contributes to the overall RTT, including frame time, target command slack, etc.")]
[Range(0, 16)]
public uint TargetCommandSlack
Field Value
Type | Description |
---|---|
uint |
Remarks
Higher values increase command arrival reliability, at the cost of a longer client prediction window (which can itself degrade gameplay performance).