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.

Pausing Physics Simulation

Discussion in 'Physics for ECS' started by roryo, Oct 21, 2020.

  1. roryo

    roryo

    Joined:
    May 21, 2009
    Posts:
    1,479
    Does anyone know if there is a way to simply pause the physics simulation and turn it back on at a later time? Not just turn all entities to isKinematic in PhysicsMassOverride, but actually stop the system from processing the simulation?
     
  2. petarmHavok

    petarmHavok

    Joined:
    Nov 20, 2018
    Posts:
    461
    If you set StepPhysicsWorld.Enabled to false, it will not update. However, building and exporting of the world will still happen. For that, you need to disable BuildPhysicsWorld and ExportPhysicsWorld. Also, maybe EndFramePhysicsSystem. Basically all the systems you don't want to update while paused.

    Setting timestep to 0 is another thing people do, but keep in mind that this has performance implications as most of the step will still be run, plus you could get collision/trigger events even when nothing is moving. So I'd stick with disabling systems.
     
  3. roryo

    roryo

    Joined:
    May 21, 2009
    Posts:
    1,479
    Last edited: Oct 21, 2020
    petarmHavok likes this.