Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Pausing Physics Simulation

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

  1. roryo

    roryo

    Joined:
    May 21, 2009
    Posts:
    1,482
    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,482
    Last edited: Oct 21, 2020
    petarmHavok likes this.