Struct ClientServerTickRate
The ClientServerTickRate singleton is used to configure the client and server simulation time step,
server packet send rate and other related settings.
The singleton entity is automatically created for the clients in the Network
It is not mandatory to set all the fields to a proper value when creating the singleton. It is sufficient to change only the relevant setting, and call the Resolve
- the maximum number of tick per frame
- the maximum number of tick per frame
- tick batching (Max
Simulation and others.Step Batch Size
Implements
Inherited Members
Namespace: Unity.NetCode
Assembly: Unity.NetCode.dll
Syntax
[Serializable]
public struct ClientServerTickRate : IComponentData, IQueryTypeParameter
Fields
MaxSimulationStepBatchSize
If the server cannot keep up with the simulation frequency with running MaxSimulationStepsPerFrame
ticks it is possible to allow each tick to run with a longer delta time in order to keep the game
time updating correctly. This means that instead of running two ticks with delta time N each, the
system will run a single tick with delta time 2*N. It is a less expensive but more inaccurate way
of dealing with server performance spikes, it also requires the game logic to be able to handle it.
Declaration
public int MaxSimulationStepBatchSize
Field Value
Type | Description |
---|---|
int |
MaxSimulationStepsPerFrame
If the server updates at a lower rate than the simulation tick rate it will perform multiple ticks in the same frame. This setting puts a limit on how many such updates it can do in a single frame. When this limit is reached the simulation time will update slower than real time. The network tick rate only applies to snapshots, the frequency commands and RPCs is not affected by this setting.
Declaration
public int MaxSimulationStepsPerFrame
Field Value
Type | Description |
---|---|
int |
NetworkTickRate
The rate at which the server sends snapshots to the clients. This can be lower than than the simulation frequency which means the server only sends new snapshots to the clients every N frames. The effect of this on the client is similar to having a higher ping, on the server it will save CPU time and bandwidth.
Declaration
public int NetworkTickRate
Field Value
Type | Description |
---|---|
int |
PredictedFixedStepSimulationTickRatio
Multiplier used to calculate the tick rate/frequency for the Predicted
Declaration
public int PredictedFixedStepSimulationTickRatio
Field Value
Type | Description |
---|---|
int |
SimulationTickRate
The fixed simulation frequency on the server and prediction loop. The client can render at a higher or lower rate than this.
Declaration
public int SimulationTickRate
Field Value
Type | Description |
---|---|
int |
TargetFrameRateMode
If the server is capable of updating more often than the simulation tick rate it can either
skip the simulation tick for some updates (BusyWait
) or limit the updates using
Application.TargetFrameRate
(Sleep
). Auto
makes it use Sleep
for dedicated server
builds and BusyWait
for client and server builds (as well as the editor).
Declaration
public ClientServerTickRate.FrameRateMode TargetFrameRateMode
Field Value
Type | Description |
---|---|
Client |
Properties
ClampPartialTicksThreshold
On the client, Netcode attempts to align its own fixed step with the render refresh rate, with the goal of reducing Partial ticks, and increasing stability. Defaults to 5 (5%), which is applied each way: I.e. If you're within 5% of the last full tick, or if you're within 5% of the next full tick, we'll clamp. -1 is 'turn clamping off', 0 is 'use default'. Max value is 50 (i.e. 50% each way, leading to full clamping, as it's applied in both directions).
Declaration
public int ClampPartialTicksThreshold { readonly get; set; }
Property Value
Type | Description |
---|---|
int |
Remarks
High values will lead to more aggressive alignment, which may be perceivable (as we'll need to shift time further).
PredictedFixedStepSimulationTimeStep
The fixed time used to run the physics simulation. Is always an integer multiple of the SimulationFixedTimeStep.
The value is equal to 1f / (Simulation
Declaration
public float PredictedFixedStepSimulationTimeStep { get; }
Property Value
Type | Description |
---|---|
float |
SendSnapshotsForCatchUpTicks
If the server has to run multiple simulation ticks in the same frame the server can either send snapshots for all those ticks or just the last one.
Declaration
public bool SendSnapshotsForCatchUpTicks { get; set; }
Property Value
Type | Description |
---|---|
bool |
SimulationFixedTimeStep
1f / SimulationfixedDeltaTime
.
Declaration
public float SimulationFixedTimeStep { get; }
Property Value
Type | Description |
---|---|
float |
Methods
ResolveDefaults()
Set all the properties that hasn't been changed by the user or that have invalid ranges to a proper default value.
In particular this guarantee that both Network
Declaration
public void ResolveDefaults()