Collider
A Collider is an invisible shape around a GameObject — it defines the physics collision boundary without needing the Mesh's exact geometry for every contact.
Imagine...
A Collider is like a protective bubble around an object. A character with thousands of polygons cannot have the game test every triangle for hits — far too slow. Unity wraps the character in a simple shape (box, sphere, capsule) instead. That bubble is the Collider. You cannot see it, but every collision is "felt" through it.
The concept in detail
A Collider is the component that defines a GameObject’s
physical shape in Unity Physics. It is fully separate from the Mesh Renderer — an object can
have a Collider with no visuals (a hidden zone), or visuals with no Collider (decoration).
Unity’s four main 3D types are BoxCollider, SphereCollider,
CapsuleCollider, and MeshCollider.
Performance, fastest to slowest:
Sphere → Box → Capsule → Mesh. MeshCollider copies the
Mesh exactly but is expensive — only use it when you need pixel-perfect terrain or static
props. For a moving character, CapsuleCollider is the usual pick: it fits a
standing body and handles stairs smoothly.
A Collider can run in Trigger mode (
isTrigger = true) to detect overlaps with no physical response. When it is not a
trigger, it produces real contact forces. Several colliders on one object or its children are a
Compound Collider — the usual way to approximate a
complex shape without a MeshCollider.
From Unity 6 onward, Physics Shapes 2D and Physics Material attach directly to the Collider so you can control friction and bounciness per surface.
Collider types
BoxCollider
A box. Fast — walls, floors, crates.
SphereCollider
A sphere. Fastest — bullets, fruit, round rocks.
CapsuleCollider
A capsule. Best for standing characters.
MeshCollider
Matches the Mesh exactly. Slowest — static props only.
Compound Collider
Combine several primitive colliders (Box + Sphere…) on the object or its children to approximate a complex shape — faster than a MeshCollider, more accurate than a single primitive.
Hands-on steps
Pick the right Collider type
Add Component → Physics → choose Box/Sphere/Capsule/MeshCollider to match the object shape.
Resize it in the Inspector
Click "Edit Collider" (pencil icon) to drag in the Scene view, or change Center, Size, Radius in the Inspector.
Check the Gizmo color
Colliders draw green when idle and red while overlapping. Turn on Gizmos in the Scene view to see them.
Add a Physics Material (optional)
Create → Physics Material → assign it to the Collider Material slot to tune friction and bounce.
Set Layers for the Collision Matrix
Project Settings → Physics → Layer Collision Matrix: control which layers collide, and skip work you do not need.
Interactive simulator
Pick a Collider type and drop shapes to see how they bounce on the ground and each other.
Code example
BasicRead and tweak a Collider from script at runtime.
using UnityEngine;
public class ColliderExample : MonoBehaviour
{
void Start()
{
// Get the Collider on this object
Collider col = GetComponent<Collider>();
// Inspect the Collider's world bounds
Debug.Log("Size: " + col.bounds.size);
Debug.Log("Center: " + col.bounds.center);
// Enable / disable the Collider
col.enabled = false; // Temporarily ignore collisions
col.enabled = true;
// Resize a BoxCollider specifically
BoxCollider box = GetComponent<BoxCollider>();
if (box != null)
box.size = new Vector3(2f, 1f, 2f);
}
}Code example
AdvancedDetect objects in a box with OverlapBox — no Rigidbody required.
using UnityEngine;
// Find every body inside a box without a physical collision
public class AreaDetector : MonoBehaviour
{
public Vector3 detectionSize = new Vector3(5f, 5f, 5f);
public LayerMask targetLayer;
void Update()
{
// OverlapBox: all Colliders in the box, no Rigidbody needed
Collider[] hits = Physics.OverlapBox(
transform.position,
detectionSize / 2f,
transform.rotation,
targetLayer
);
foreach (Collider hit in hits)
{
Debug.Log("Detected: " + hit.name);
}
}
// Draw the detection volume in the Scene view
void OnDrawGizmosSelected()
{
Gizmos.color = new Color(0.2f, 1f, 0.2f, 0.3f);
Gizmos.DrawCube(transform.position, detectionSize);
Gizmos.color = new Color(0.2f, 1f, 0.2f, 1f);
Gizmos.DrawWireCube(transform.position, detectionSize);
}
}📌 Quick recap
- ▸Sphere is fastest; Mesh is most accurate and slowest
- ▸CapsuleCollider is the default for humanoid characters
- ▸Compound = several primitive colliders instead of a MeshCollider
- ▸isTrigger=true → detect without a contact force
- ▸Layer Collision Matrix controls who-hits-who
⚠️ Common mistakes
❌ MeshCollider with Convex=false on a moving body
A non-convex MeshCollider cannot pair with a Dynamic Rigidbody — Unity errors
✅ Enable Convex, or use a Compound Collider instead
❌ Collider much smaller than the visible mesh
Players see a bullet miss but still take a hit — feels unfair
✅ Turn on Gizmos and match Collider size to the mesh