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.
To install the 2D Physics Core package, follow these steps:
To create a GameObject that falls under gravity, follow these steps:
2, so the GameObject starts higher up with room to fall.To create a static ground for the circle to land on, follow these steps:
Create an empty GameObject.
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.
Select Add Component again, then Physics 2D (Core) > Physics Area Path.
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.
Enter Play mode. The circle falls and lands on the ground.
To connect objects together, add a Physics Constraint component. Follow these steps:
Select the circle GameObject.
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.
Drag the ground GameObject into the Pose B Target field.
In the Definition section, set Distance to 3. This sets the minimum distance between the two GameObjects.
Enter Play mode. The circle stops falling once it’s 3 meters from the ground.