Understand how 2D Physics Core objects collide, including collision types, contact filters, and layers.
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.
A collision happens when two objects occupy the same physical space.
To detect a collision, Unity uses the shapes that the Physics Area components on a GameObject create. A Physics Area component is the 2D Physics Core equivalent of a Collider 2D component in the standard 2D physics system, and stores a PhysicsShape object.
Shapes don’t need to be the same shape as the body, and you can add multiple shapes to one body.
For more information about the available area types, refer to Physics Pose and Physics Area components.
How a shape reacts to a collision depends on the Is Trigger property of its Physics Area component.
Trigger shapes have the following limitations:
Each area has a contact filter, which determines the other areas it collides with. A contact filter has the following properties:
For more information, refer to Configure collisions between 2D Physics Core objects.
By default, layers are the 32 GameObject layers, and all objects are on the built-in layer called Default. 2D Physics Core also provides its own set of 64 layers, which you can use instead of the GameObject layers. For more information, refer to Set 2D Physics Core to use its own set of layers.
All areas can produce events when they overlap or collide with another shape, so you can implement callback methods or update properties.
| Event type | When the event happens | Property to enable in an Area component |
|---|---|---|
| Trigger event | When the area starts and ends overlapping another shape, regardless of whether Is Trigger is enabled. | Enable Trigger Events. |
| Contact event | When the shape starts and ends touching another shape. | Enable Contact Events. This property only has an effect if the area is attached to a kinematic or dynamic pose. |
| Hit events | When the shape collides faster than the speed set in the Contact Hit Event Threshold property of the world. The default is 1 meter per second. For more information, refer to Physics Simulation Definition asset reference. | Enable Hit Events. This property only has an effect if the area is attached to a kinematic or dynamic pose. |
For more information, refer to Detect contact between 2D Physics Core objects.