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 NetworkStreamReceiveSystem
first update if not present.
On the server, by countrary, the entity is never automatically created and it is up to the user to create the singletong instance if
they need to.
This behaviour is asymmetric because the client need to have this singleton data synced with the server one. It is like
this for compatibility reason and It may be changed in the future.
In order to configure these settings you can either:
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 ResolveDefaults() method to
configure the fields that does not have a value set.
class MyCustomClientServerBootstrap : ClientServerBootstrap
{
override public void Initialize(string defaultWorld)
{
base.Initialise(defaultWorld);
var customTickRate = new ClientServerTickRate();
//run at 30hz
customTickRate.simulationTickRate = 30;
customTickRate.ResolveDefault();
foreach(var world in World.All)
{
if(world.IsServer())
{
//In this case we only create on the server, but we can do the same also for the client world
var tickRateEntity = world.EntityManager.CreateSingleton(new ClientServerTickRate
{
SimulationTickRate = 30;
});
}
}
}
}
The ClientServerTickRate settings are synced as part of the of the initial client connection handshake.
(ClientServerTickRateRefreshRequest data).
The ClientServerTickRate should also be used to customise other server only timing settings, such as
See the individual fields documentation for more information.
Assembly: solution.dll
Syntax
[Serializable]
public struct ClientServerTickRate : IComponentData, IQueryTypeParameter
Fields
Name |
Description |
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.
|
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.
|
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.
|
PredictedFixedStepSimulationTickRatio
|
Multiplier used to calculate the tick rate/frequency for the PredictedFixedStepSimulationSystemGroup.
The group rate must be an integer multiple of the SimulationTickRate.
Default value is 1, meaning that the PredictedFixedStepSimulationSystemGroup run at the same frequency
of the prediction loop.
The calculated frequency is 1.0/(SimulationTickRate*PredictedFixedStepSimulationTickRatio)
|
SimulationTickRate
|
The fixed simulation frequency on the server and prediction loop. The client can render
at a higher or lower rate than this.
|
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).
|
Properties
Methods
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.