Version: Unity 6.7 Beta (6000.7)
Language : English
Introduction to 2D Physics Core
Creating a scene with 2D Physics Core

Get started with 2D Physics Core

Understand how to create a simple scene with 2D Physics Core components, including using Physics Pose and Physics Area components to create a GameObject that reacts to physics, and a Physics Constraint component to connect two GameObjects together.

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.

Install the package

To install the 2D Physics Core package, follow these steps:

  1. From the main menu, select Window > Package Manager to open the Package Manager window.
  2. In the Sources section, select Unity Registry.
  3. Select 2D Physics Core from the list of packages.
  4. Select Install.

Create a falling circle

To create a GameObject that falls under gravity, follow these steps:

  1. Create an empty GameObject.
  2. Select the GameObject, then in the Inspector window select Add Component, then Physics 2D (Core) > Physics Pose.
  3. Set Body Type to Dynamic.
  4. Select Add Component again, then Physics 2D (Core) > Physics Area Circle.
  5. In the Transform component, set the Y value of Position to 2, so the GameObject starts higher up with room to fall.
  6. Enter Play mode. The GameObject falls under gravity.

Create ground

To create a static ground for the circle to land on, follow these steps:

  1. Create an empty GameObject.

  2. Select the GameObject, then in the Inspector window select Add Component, then Physics 2D (Core) > Physics Pose.

    Leave Body Type set to Static, so the ground doesn’t move.

  3. Select Add Component again, then Physics 2D (Core) > Physics Area Path.

  4. In the Scene view, edit the path’s vertices to form a flat line underneath where the circle will land. For more information, refer to Visualize and edit 2D Physics Core scenes.

  5. Enter Play mode. The circle falls and lands on the ground.

Create a connection between two objects

To connect objects together, add a Physics Constraint component. Follow these steps:

  1. Select the circle GameObject.

  2. In the Inspector window, select Add Component, then Physics 2D (Core) > Physics Constraint Distance.

    In the Physics Constraint Distance component, Unity automatically sets Pose A Source to the circle GameObject.

  3. Drag the ground GameObject into the Pose B Target field.

  4. In the Definition section, set Distance to 3. This sets the minimum distance between the two GameObjects.

  5. Enter Play mode. The circle stops falling once it’s 3 meters from the ground.

Additional resources

Introduction to 2D Physics Core
Creating a scene with 2D Physics Core