Version: Unity 6.7 Beta (6000.7)
Language : English
Creating multiple simulation worlds with 2D Physics Core
Physics Simulation component reference

Create multiple simulation worlds with 2D Physics Core

Create additional physics worlds so you can simulate separate groups of objects under different conditions, such as different gravity values, in the same scene.

Note: This documentation is about using Pose, Area, and Constraint components. To use 2D physics in the Unity Editor using components like the Rigidbody 2D component, refer to 2D physics instead.

Adjust the properties of the default world

Unity automatically creates a default world that every 2D Physics Core component belongs to. Unity creates or recreates the default world at the following times:

  • When the Editor starts.
  • When you enter or exit Play mode.
  • When your built application starts.

To adjust the properties of the default world, refer to Configure global 2D Physics Core settings.

Create your own world

To create your own world, for example to have two areas with different gravity values in the same scene, follow these steps:

  1. In the Project window, right-click and select Create > 2D > Physics (Core) > Simulation > Simulation World.
  2. Select the GameObject you want to add to the new world.
  3. Add or select a Physics Pose component, then in the Simulation section set Simulation Source to Simulation World.
  4. Drag the Physics Simulation World asset you created into the Simulation World property, or select the picker ().

Repeat these steps for every object you want to add to the new world.

For more information, refer to Physics Simulation World asset reference.

Configure your own world

To adjust a world’s properties, such as gravity, follow these steps:

  1. Select the Physics Simulation World asset in the Project window.
  2. In the Inspector window, select Make Asset to create a Physics Simulation Definition asset.
  3. Save the asset.
  4. Select the Physics Simulation Definition asset in the Project window, then adjust its properties in the Inspector window.

For more information, refer to Physics Simulation Definition asset reference.

Keep a world alive

By default, Unity destroys a world when nothing references it anymore, for example if you disable every Physics Pose component in the world. If you re-enable a component, Unity creates the world again from the Physics Simulation World asset.

To keep a world alive, create a GameObject with a Physics Simulation component instead. Follow these steps:

  1. Create an empty GameObject.
  2. In the Inspector window, select Add Component, then Physics 2D (Core) > Physics Simulation.
  3. Select Make Asset to create a Physics Simulation World asset, or drag an existing Physics Simulation World asset into the Simulation World property.

Unity now keeps the world alive for as long as the Physics Simulation component stays enabled.

To keep this GameObject alive when a new scene loads, enable Persist Across Scenes. This affects the whole GameObject, not only the Physics Simulation component.

For more information, refer to Physics Simulation component reference.

Additional resources

Creating multiple simulation worlds with 2D Physics Core
Physics Simulation component reference