Menu
CoddyTech

Collider Shapes

Part of the Physics and Gameplay section of Coddy's Unity journey. Lesson 13 of 63.

Physics never looks at the mesh you see: it uses the object's collider, and the collider can be much simpler. Unity's three basic shapes cover most needs. A BoxCollider (size, center) fits crates, walls, floors and buildings. A SphereCollider (radius) fits balls; it is the cheapest shape to test, and a sphere rolls when friction turns it. A CapsuleCollider (radius, height, direction) is a cylinder with round ends, and its height counts the ends.

The capsule is the usual shape for characters. Its rounded bottom slides over small steps and the seams between floor tiles, where a box's corner would catch, and its sides glance off corners instead of snagging. A capsule on a Rigidbody would tip over like a bottle, so character Rigidbodies freeze rotation (rb.freezeRotation = true) and the code turns the character itself.

Each primitive brings a matching collider: Cube a BoxCollider, Sphere a SphereCollider, Capsule a CapsuleCollider. Unity has no cylinder collider, so the Cylinder primitive gets a CapsuleCollider, with round ends. A MeshCollider follows an imported model's own triangles: right for detailed scenery that never moves, slower to test, and on a moving Rigidbody it must be marked Convex. For a complicated object that moves, a few simple colliders on its child objects are faster than one mesh.

Try it yourself

This lesson doesn't include a code challenge.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Physics and Gameplay