Search Unity

How change physics timeScale?

Discussion in 'Physics for ECS' started by UDN_08c892cf-fb37-48c2-920c-0e8c4758982f, Feb 15, 2020.

  1. UDN_08c892cf-fb37-48c2-920c-0e8c4758982f

    UDN_08c892cf-fb37-48c2-920c-0e8c4758982f

    Joined:
    Aug 15, 2017
    Posts:
    1
    I need change physics simulation speed, just like Time.timeScale in old unity physics.
    In this forum proposed to change Time.fixedDeltaTime, but it doesn’t help me. if I set to Time.fixedDeltaTime = 0, then the physical objects continue to move, albeit at a lower speed.
     
  2. phobos2077

    phobos2077

    Joined:
    Feb 10, 2018
    Posts:
    350
    I would like to know this as well. Fixed time step should not control the speed of simulation, that doesn't make sense. Either I missed an important piece of configuration or this is an embarrassing bug on Unity's side.
     
  3. apaxnid

    apaxnid

    Joined:
    Nov 18, 2012
    Posts:
    35
    this is from StepPhysicsWorld.cs
    Code (CSharp):
    1.  
    2. #if !UNITY_DOTSPLAYER
    3.             float timeStep = UnityEngine.Time.fixedDeltaTime;
    4. #else
    5.             float timeStep = Time.DeltaTime;
    6. #endif
    You can make hacks like changing Time.fixedDeltaTime before stepphysicsworld and reverse it to normal after. You can even change simulation type to NoPhysics if you don't want to step physics simulation this frame. Or you can edit ComponentSystemGroup.cs and make SetFixedTimeStep method public and then in custom world bootstrap set SimulationSystemGroup's fixed time step. Or you can wait. Unity will figure out proper API soon™ enough:)
     
    phobos2077 likes this.