docs.unity.cn
Search Results for

    Show / Hide Table of Contents

    Field 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

    • the maximum number of tick per frame
    • the maximum number of tick per frame
    • tick batching (MaxSimulationStepBatchSize and others.
    See the individual fields documentation for more information.
    Namespace: Unity.NetCode
    Assembly: solution.dll
    Syntax
    public ClientServerTickRate ClientServerTickRate
    Returns
    Type Description
    ClientServerTickRate
    In This Article
    Back to top
    Copyright © 2023 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)