Loading lessons...
Colliders & Triggers
Colliders & Triggers
Collider Components
A Collider defines the physical shape of a GameObject for collision detection.
- Box Collider: A rectangular box shape.
- Sphere Collider: A spherical boundary.
- Capsule Collider: A capsule shape.
- Mesh Collider: Uses the 3D model geometry itself for absolute accuracy.
Physical Collisions
When two solid objects bump into each other, physical contact occurs. Use:
OnCollisionEnter(Collision collision): Runs when contact is first made.OnCollisionStay(Collision collision): Runs repeatedly while contact remains.OnCollisionExit(Collision collision): Runs when contact ends.
Triggers (Non-physical boundaries)
If you check the Is Trigger box on a Collider component, the collider no longer acts as a solid object. Objects pass straight through it. For trigger interactions, use:
OnTriggerEnter(Collider other): Runs when an object enters the zone.OnTriggerStay(Collider other): Runs while an object stays in the zone.OnTriggerExit(Collider other): Runs when an object leaves the zone.
Rule of thumb
For physics collision/trigger events to fire:
- Both objects must have Collider components.
- At least one of the objects must have an active Rigidbody component.
TL;DR
- Physical collisions block movement and trigger
OnCollision...methods. - Triggers let objects pass through, firing
OnTrigger...methods. - One of the colliding objects must have a Rigidbody for events to fire.