UNITY COLLIDERS EXPLAINED: COLLISION & TRIGGER SETUP

Master solid physics collisions vs phantom trigger volumes, C# callback events, and mobile performance optimization.

Collisions vs Triggers: The Golden Rule

Collisions (OnCollisionEnter): Block movement physically and require both objects to have non-trigger Colliders, with at least one having a non-kinematic Rigidbody.
Triggers (OnTriggerEnter): Allow objects to pass through freely (like checkpoint zones or bullet hits) and execute as long as one Collider has Is Trigger = true and at least one has a Rigidbody.

1

C# Event Callbacks Code Examples

CollisionDetector.cs (C#)
using UnityEngine;

public class CollisionDetector : MonoBehaviour
{
    // SOLID PHYSICAL COLLISION (e.g. Car hitting a concrete barrier)
    private void OnCollisionEnter(Collision collision)
    {
        Debug.Log($"Impact with: {collision.gameObject.name} at {collision.relativeVelocity.magnitude} m/s");
        
        // Access exact contact point for spark particle effects
        ContactPoint contact = collision.GetContact(0);
        // Spawn sparks at contact.point with contact.normal
    }

    // PHANTOM TRIGGER ZONE (e.g. Missile entering blast radius, checkpoint ring)
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Pickup"))
        {
            Debug.Log($"Collected: {other.name}");
            Destroy(other.gameObject);
        }
    }
}
2

Choosing the Right Collider Type

  • Sphere Collider: The most computationally efficient primitive in PhysX. Always use for cannonballs, grenade proximity sensors, and aircraft nose radars.
  • Capsule Collider: Perfect for humanoid characters and vertical rockets. Slides smoothly over stair edges without snagging.
  • Box Collider: Ideal for buildings, crates, vehicle chassis, and rectangular trigger zones.
  • Mesh Collider: Most expensive. Use only for complex static terrain, and always enable Convex if attaching to a moving Rigidbody.

Colliders Not Triggering Events?

Read our step-by-step fix: Collider Not Detecting Collisions Fix →

Practical Combat Implementations