Set which 2D Physics Core objects collide with each other, using 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.
By default, the following applies:
To change this behavior, do the following:
Note: To configure how a physics object reacts to a collision, for example how bouncy it is, use the Surface Material properties in the Definition section of its Physics Area component.
Follow these steps:
The Contact Filter properties now use the layers in the Layers section of the Settings window.
Use the Layers section to add, edit, or remove layers. For more information, refer to Physics Core 2D reference.
To set which objects an area collides with, follow these steps:
To use the same contact settings for several components, use a Physics Contact Filter asset. For more information, refer to Share properties across multiple 2D Physics Core components.
To set which objects an area collides with in a script, refer to the PhysicsShape.ContactFilter API.
Because physics objects move in steps, fast-moving objects can sometimes pass through other objects without activating a collision. This is called tunneling.
2D Physics Core automatically uses continuous collision detection to prevent tunneling when dynamic objects approach static objects. However, if a very fast-moving object still passes through another object, enable Fast Collisions Allowed on its Physics Pose component. Enabling this property can reduce performance. For more information, refer to Physics Pose component reference.