How to Create Colliders on Objects in Unity

Colliders are one of the most fundamental building blocks in Unity game development. Whether you're making a platformer, a racing game, or a 3D physics simulation, colliders define how objects interact with each other physically — controlling everything from bouncing and sliding to triggering events when a player enters a zone. Understanding how to add and configure them correctly makes the difference between a game that feels solid and one that feels broken.

What Is a Collider in Unity?

A collider is an invisible shape attached to a GameObject that Unity's physics engine uses to detect contact and collisions. It doesn't have to match the visual mesh of the object exactly — in fact, for performance reasons, it usually shouldn't.

Unity separates the visual representation (the mesh renderer) from the physical representation (the collider). This means you can have a complex 3D model rendered on screen while the physics engine interacts with a much simpler shape underneath.

Types of Colliders Available in Unity

Unity offers several collider types, each suited to different situations:

Collider TypeShapeBest Used For
Box ColliderRectangular boxWalls, floors, crates, platforms
Sphere ColliderSphereBalls, projectiles, rounded objects
Capsule ColliderCylinder with rounded endsPlayer characters, NPCs
Mesh ColliderExact mesh shapeDetailed terrain or static objects
Wheel ColliderSpecialized wheel physicsVehicle wheels
Terrain ColliderMatches Unity Terrain assetLarge terrain surfaces

For 2D projects, Unity has equivalent 2D versions: Box Collider 2D, Circle Collider 2D, Polygon Collider 2D, and Edge Collider 2D.

How to Add a Collider to a GameObject 🎮

Method 1: Using the Inspector

  1. Select your GameObject in the Hierarchy panel.
  2. In the Inspector, click Add Component.
  3. Search for the collider type you want (e.g., "Box Collider").
  4. Click it to attach it to the object.

Once added, the collider appears as a green outline around your object in the Scene view. You can toggle visibility using the Gizmos button in the Scene view toolbar.

Method 2: Adding via the Menu Bar

With your GameObject selected:

  • Go to Component → Physics → [Collider Type] for 3D projects
  • Go to Component → Physics 2D → [Collider Type] for 2D projects

Method 3: Adding at Runtime via Script

You can also attach colliders through C# code: