Trigger colliders detect when objects enter or exit their area but do not cause physical reactions. Collision colliders detect physical impacts and cause objects to respond physically.
void OnTriggerEnter(Collider other) {
Debug.Log("Triggered by " + other.name);
}
void OnCollisionEnter(Collision collision) {
Debug.Log("Collided with " + collision.gameObject.name);
}When a collider is set as a trigger, Unity calls OnTriggerEnter when another collider enters it. OnCollisionEnter is called only if the collider is not a trigger.
OnCollisionEnter requires a Collision parameter. OnTriggerEnter requires a Collider parameter. Extra parameters are not allowed.
Trigger colliders avoid expensive physics calculations because they do not cause physical responses, making them more efficient for simple detection.
For OnTriggerEnter to be called, at least one collider must have a Rigidbody component that is not kinematic. Missing or incorrect Rigidbody setup often causes the event not to fire.