Master solid physics collisions vs phantom trigger volumes, C# callback events, and mobile performance optimization.
⏱️ 6 Min Read🛡️ Colliders & Triggers🎮 Unity 2021 • 2022 • Unity 6⚡ High Performance
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.
Primitive Colliders vs Compound Colliders vs Mesh Colliders
For high-speed mobile games, MeshColliders are computationally expensive. Creating a compound collider using a parent GameObject with multiple child Box and Capsule colliders is 10x faster for PhysX calculation than complex concave mesh trees.
Physics Materials: Bounciness and Dynamic Friction
Attach a Physics Material to your colliders to dictate real-world surface reactions. Configure Friction Combine and Bounce Combine to Multiply or Minimum for consistent wheel traction and aircraft runway landing deceleration.