Skip to content

Collisions and triggers

↑

A collision callback is for physical contact between colliders; a trigger callback is for overlap detection without normal collision response. The callbacks have distinct parameter types and prerequisites. This page covers Unity’s 3D physics; the 2D methods have a 2D suffix.

Message Use it for
OnCollisionEnter(Collision collision) First frame of physical contact
OnCollisionStay(Collision collision) Continued contact
OnCollisionExit(Collision collision) Contact ended
OnTriggerEnter(Collider other) Another collider entered a trigger
OnTriggerStay(Collider other) Another collider remains in a trigger
OnTriggerExit(Collider other) Another collider left a trigger
Unity C# | PickupZone.cs
using UnityEngine;
public sealed class PickupZone : MonoBehaviour
{
private void OnTriggerEnter(Collider other)
{
if (!other.CompareTag("Player")) return;
Debug.Log("The player entered the pickup zone.");
}
}

Add a collider to the zone, enable Is Trigger, and ensure the two objects meet Unity’s Rigidbody and collider requirements for a trigger event. Do not assume that any pair of colliders will generate a message.

Unity C# | ImpactReport.cs
using UnityEngine;
public sealed class ImpactReport : MonoBehaviour
{
private void OnCollisionEnter(Collision collision)
{
Debug.Log($"Hit {collision.gameObject.name}");
}
}
  1. Check whether the colliders are enabled and set to Is Trigger for the intended behavior.
  2. Confirm the relevant object has a compatible Rigidbody and that the 3D APIs are being used with 3D components.
  3. Check the Layer Collision Matrix in Physics settings.
  4. Make sure the callback signature is exact, including parameter type and capitalization.
  5. Test a minimal two-object scene before adding complex gameplay rules.

Read Rigidbody and movement for the movement side of the interaction.