Version: Unity 6.3 LTS (6000.3)
Language : English
Collisions and interactions in the LowLevelPhysics2D API
Configure collisions between LowLevelPhysics2D API objects

Introduction to collision in the LowLevelPhysics2D API

Note: This documentation is about writing C# scripts using the LowLevelPhysics2D API. To use 2D physics in the Unity Editor using components like the Rigidbody 2D component, refer to 2D physics instead.

In Unity, a collisionA collision occurs when the physics engine detects that the colliders of two GameObjects make contact or overlap, when at least one has a Rigidbody component and is in motion. More info
See in Glossary
happens when two objects occupy the same physical space.

To detect collision between LowLevelPhysics2D API objects, Unity uses the PhysicsShape objects attached to the PhysicsBody. The shape defines the physics body for the purposes of physical collisions. The shape is similar to the ColliderAn invisible shape that is used to handle physical collisions for an object. A collider doesn’t need to be exactly the same shape as the object’s mesh - a rough approximation is often more efficient and indistinguishable in gameplay. More info
See in Glossary
2D component in the regular 2D physics system.

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 adding a shape, refer to Create a physics object.

Collision types

In the LowLevelPhysics2D API, collisions are enabled by default.

How a shape reacts to collisions depends on its type:

  • Collider: The shape can’t enter other objects. When the shape makes contact with another shape, it reports a contact event. This is the default.
  • Trigger: The shape goes through other objects. When the shape enters another shape, it reports a trigger event.

For more information, refer to Configure collisions between LowLevelPhysics2D API objects.

To detect collisions and overlaps using callbacks or events, refer to Detect collisions between objects.

Collision layers

Unity uses layers to determine which objects collide with each other.

By default the following applies:

  • Objects use GameObject layers, and all objects are on the built-in layer called Default.
  • Objects collide with objects on all other layers.

To change this behavior, change the layers that objects are on, and the layers they collide with. For more information, refer to Configure collisions between 2D physics objects.

In the LowLevelPhysics2D API, you can use a different set of 64 layers, instead of the standard set of 32 GameObjectThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
See in Glossary
layers. For more information, refer to Use up to 64 layers.

Additional resources

Collisions and interactions in the LowLevelPhysics2D API
Configure collisions between LowLevelPhysics2D API objects