Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug 1.0.0-exp.8: Changing SimulationTickRate to anything else than 60 breaks physics simulation

Discussion in 'NetCode for ECS' started by Occuros, Oct 2, 2022.

  1. Occuros

    Occuros

    Joined:
    Sep 4, 2018
    Posts:
    284
    In 0.51 the simulation rate could be modified by creating a `
    ClientServerTickRate` singleton and adjusting the Simulation rate.

    Now if I set any value other than 60, the physics simulation seems to break (from not working at all at 72, to multiple errors for prediction errors at 30).

    Is there anything else needed than creating the singleton to have a different simulation rate than the default 60?
     
  2. jonathan-hertz

    jonathan-hertz

    Unity Technologies

    Joined:
    Jan 15, 2020
    Posts:
    11
    Hi Occuros, thanks for reporting! I have managed to reproduce the issue where the rate is set above 60, but did not see the same issues when going below 60. Can you provide more info or perhaps report a bug through the editor so we can get the project to reproduce it?
     
    Occuros likes this.
  3. Occuros

    Occuros

    Joined:
    Sep 4, 2018
    Posts:
    284
    After machine restart, even with multiple tests of varying framerates, we didn't manage to reproduce it with lower than 60 fps.

    So it seems only values of above 60 provide consistent issues.
     
    jonathan-hertz likes this.
  4. jonathan-hertz

    jonathan-hertz

    Unity Technologies

    Joined:
    Jan 15, 2020
    Posts:
    11
    Great, we've managed to find out why the bug is happening.
    PredictedFixedStepSimulationSystemGroup.RateManager.Timestep
    needs to be a multiple of the SimulationTickRate. So you can add a system that changes it, something like this:

    Code (CSharp):
    1. if (TryGetSingletonEntity<ClientServerTickRate>(out var tickRateEntity))
    2. {
    3.     var tickRate = EntityManager.GetComponentData<ClientServerTickRate>(tickRateEntity);
    4.     tickRate.ResolveDefaults();
    5.     World.GetExistingSystemManaged<PredictedFixedStepSimulationSystemGroup>().RateManager.Timestep = 1f / tickRate.SimulationTickRate;
    6. }
    We will fix this for the proper 1.0 release so this should not be necessary.
     
    Occuros likes this.