# 2. Colliders and Physics Materials Part of [[Physics 3D]]. Previous: [[1. Rigidbody Fundamentals]]. Next: [[3. Layers Matrix and Queries]]. **Docs:** [Configure Rigidbody colliders](https://docs.unity3d.com/6000.5/Documentation/Manual/rigidbody-configure-colliders.html) · [Physics Material asset](https://docs.unity3d.com/6000.5/Documentation/Manual/class-PhysicsMaterial.html) · [Combine modes](https://docs.unity3d.com/6000.5/Documentation/Manual/collider-surfaces-combine.html) ## 2.1 Collider + Rigidbody pairing Colliders define **shape**. Rigidbodies define **dynamics**. Collision response between two bodies requires colliders on the participants; a Rigidbody with **no** collider will not collide ([configure colliders](https://docs.unity3d.com/6000.5/Documentation/Manual/rigidbody-configure-colliders.html)). Static level geometry: Collider **without** Rigidbody (or static). Moving platforms you author via animation: prefer **kinematic** Rigidbody + collider so sleep/wake and CCD interact predictably ([[1. Rigidbody Fundamentals]]). ## 2.2 Primitive vs Mesh vs Compound | Type | Use | |---|---| | **Box / Sphere / Capsule** | Cheap, stable. Player capsules, crates, triggers. | | **Mesh Collider (convex)** | Required for **non-kinematic** Rigidbodies using MeshCollider — PhysX needs convex hulls ([Manual](https://docs.unity3d.com/6000.5/Documentation/Manual/rigidbody-configure-colliders.html)). | | **Mesh Collider (non-convex)** | Static / kinematic only. Concave environment meshes. | | **Compound** | Several primitive colliders under one Rigidbody — usually better than one bad convex hull. | Authoring options Unity lists when convex hulls are too rough: split meshes in DCC, hand-build compounds, or convex decomposition tools (e.g. V-HACD mentioned in the Manual). Wheel colliders are a specialized path — see [[Car Controller]]. ## 2.3 Triggers `isTrigger = true` → overlap events without physical blocking (`OnTriggerEnter` / `Stay` / `Exit`). At least one side typically needs a Rigidbody for trigger messages (classic PhysX/Unity rule — verify with a quick playmode test if you see missing callbacks). Use triggers for: pickups, aggro volumes ([[Organic Enemy Sensing]]), damage volumes, checkpoints. ## 2.4 Physics Material (formerly Physic Material) In Unity 6 the asset / type is **Physics Material** / `PhysicsMaterial` ([Scripting API](https://docs.unity3d.com/6000.5/Documentation/ScriptReference/PhysicsMaterial.html)). Create via **Assets > Create > Physics Material**, drag onto a collider. | Property | Meaning (Manual defaults) | |---|---| | **Dynamic Friction** | Friction while sliding (0–1; default 0.6) | | **Static Friction** | Friction while at rest (0–1; default 0.6) | | **Bounciness** | 0 = clay, 1 = superball (default 0) | | **Friction Combine** / **Bounce Combine** | How two materials merge (default **Average**) | ```csharp using UnityEngine; [RequireComponent(typeof(Collider))] public class AssignIceMaterial : MonoBehaviour { void Awake() { var mat = new PhysicsMaterial("RuntimeIce") { dynamicFriction = 0.05f, staticFriction = 0.05f, bounciness = 0f, frictionCombine = PhysicsMaterialCombine.Minimum, bounceCombine = PhysicsMaterialCombine.Minimum }; var col = GetComponent<Collider>(); col.sharedMaterial = mat; // sharedMaterial avoids per-instance leak when many instances } } ``` > [!warning] Code not compiled in Unity > Not compiled in Editor for this write-up. Project-wide defaults live under **Edit > Project Settings > Physics** when a collider has no material assigned. ## 2.5 Contact callbacks (quick map) | Message | When | |---|---| | `OnCollisionEnter/Stay/Exit` | Non-trigger collider contacts (needs Rigidbody involvement per Unity rules) | | `OnTriggerEnter/Stay/Exit` | Trigger overlaps | Keep callback work light — heavy spawning belongs outside physics callbacks (buffer + process in Update/FixedUpdate). Pattern hygiene: [[Game Programming Patterns (Review)]], [[Architecture and Code Patterns]]. ## Next [[3. Layers Matrix and Queries]] — who collides with whom, and NonAlloc queries.