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

Question How to Change Simulation Timestep

Discussion in 'Physics for ECS' started by mtka, Aug 30, 2023.

  1. mtka

    mtka

    Joined:
    Oct 1, 2019
    Posts:
    4
    I am trying to increase the simulation rate of the game. Currently, it works 50 times per second and I want to increase it to 120. I am not sure how to do it but I tried this on a system and it didn't work:

    upload_2023-8-30_17-1-59.png

    If anyone knows how to do it, please let me know.
     
  2. mtka

    mtka

    Joined:
    Oct 1, 2019
    Posts:
    4
    I think I found a way to change the frequency of the simulation system with the code below:
    upload_2023-8-30_18-0-46.png

    With this, the simulation system group ticks 120 per second but SystemApi.Time.FixedDeltaTime returns 0.02 idk why.
     
    daniel-holz likes this.
  3. daniel-holz

    daniel-holz

    Unity Technologies

    Joined:
    Sep 17, 2021
    Posts:
    213
    Yes, this is exactly it. Sorry for the delay here.
    By default, we don't use the
    FixedRateSimpleManager
    , but the FixedRateCatchUpManager which tries to ensure that you have real-time simulation by stepping the physics multiple times per step forward in case you get behind.

    But, the FixedRateSimpleManager does the trick if you absolutely want to only ever have one physics step, which could be the case in performance heavy scenes in which the catch up manager would spiral out of control and worsen the situation by spending even more time than it should per frame due to the multiple stepping.
     
    mtka likes this.
  4. daniel-holz

    daniel-holz

    Unity Technologies

    Joined:
    Sep 17, 2021
    Posts:
    213
    Regarding the 0.02 value in
    SystemAPI.Time.fixedDeltaTime
    :
    This is a legacy property which you should actually not use. I will bring it up with the team that it should be deprecated as mentioned on the function.
    upload_2023-9-1_8-4-44.png

    The value you should look at to get the actual time step used when your system is stepped is
    SystemAPI.Time.DeltaTime
    .
    This will show the one you set.
     
    mtka likes this.