What colliders do and why you need them

A collider in Unity is an invisible shape attached to a game object that tells the physics engine where that object exists in space. Without a collider, your character can walk through walls, bullets pass through enemies, and objects fall through the ground. Colliders define the boundaries that the physics system recognizes — they are how Unity knows when two things have touched.

You do not see colliders in your finished game. They work behind the scenes to detect collisions, trigger events, and calculate physics responses. A wall has a collider so the player stops at it. A coin has a collider so the player can pick it up. A button has a collider so clicks register on it instead of passing through.

Unity offers several collider shapes, each suited to different objects. A cube collider works for boxes and buildings. A sphere collider works for balls and round enemies. A capsule collider works for characters. A mesh collider wraps around complex shapes but costs more performance. Choosing the right shape for each object keeps your game running smoothly.

Key Takeaways

  • Every physical object in your game needs a collider component — add it through the Inspector by clicking Add Component and selecting the collider type that matches the object's shape.
  • Box, sphere, and capsule colliders are fast and work for most objects; mesh colliders are accurate but slower and should only be used when simpler shapes will not fit.
  • Colliders must be set to "Is Trigger" if you want them to detect when something enters without blocking movement, or left unchecked if you want them to physically block objects.
  • Objects that move or fall need a Rigidbody component in addition to a collider so the physics engine knows to calculate forces on them.
  • Test colliders in Play mode by moving objects around and watching for gaps where collisions should happen but do not, then adjust the collider size or position in the Inspector.

Adding a collider to a new object

Start with an object already in your scene. Click on it in the Hierarchy panel on the left side of the screen. Look at the Inspector panel on the right — this shows all the components attached to that object. At the bottom of the Inspector, you will see a button that says "Add Component".

Click "Add Component". A search box appears. Type the name of the collider you need: "Box Collider" for rectangular objects, "Sphere Collider" for round objects, or "Capsule Collider" for tall rounded shapes like characters. Click the collider name when it appears in the dropdown. The collider component now appears in the Inspector.

The collider is now attached, but it may not fit your object perfectly. In the Inspector, you will see fields for Position and Scale under the collider component. Adjust these numbers to make the collider match your object's shape. If your collider is too small, increase the Scale values. If it is offset from the object, change the Position values. Watch the green outline in the Scene view as you adjust — that outline shows where your collider actually is.

Choosing the right collider shape

A Box Collider is a rectangular block. Use it for walls, floors, crates, buildings, and anything with straight edges. It is fast and accurate for these shapes. If you try to use a box collider on a sphere, it will not fit properly and collisions will feel wrong.

A Sphere Collider is a perfect ball. Use it for balls, round enemies, planets, or anything that rolls. It is very fast because the physics engine only needs to check the distance between centers. Do not use it for objects that are not roughly round — the collider will stick out past the object's edges.

A Capsule Collider is a cylinder with rounded ends, like a pill. Use it for characters, tall enemies, or anything upright and roughly cylindrical. It is fast and works well for things that need to move smoothly without catching on corners. Set the Height to match your character's height and adjust the Radius to match their width.

A Mesh Collider wraps around the exact shape of your 3D model. Use it only when the other shapes do not fit — for irregular rocks, complex buildings, or detailed props. Mesh colliders are much slower than the others, especially if many objects use them. Only use mesh colliders on objects that do not move, or use them sparingly on moving objects.

Setting colliders to trigger or block

By default, a collider blocks movement. If two colliders touch, the physics engine stops them from passing through each other. This is what you want for walls, floors, and solid objects.

Sometimes you want a collider to detect when something enters it without blocking movement. This is called a trigger. Use triggers for doorways that open when the player walks through, coins that disappear when collected, or damage zones that hurt the player without stopping them. To make a collider a trigger, check the "Is Trigger" box in the Inspector.

A trigger collider still detects collisions, but it does not physically block anything. You can write code that runs when something enters a trigger — for example, adding points to the score when the player touches a coin trigger, or playing a sound when they walk through a doorway trigger.

Adding a Rigidbody for physics

A collider alone is not enough if your object needs to fall, bounce, or be pushed by other objects. You also need a Rigidbody component. The Rigidbody tells the physics engine to explore gravity and forces to your object.

Click "Add Component" again and search for "Rigidbody". Add it to your object. Now the physics engine will pull your object down with gravity. If another object hits it, the Rigidbody will calculate how it should move in response.

In the Rigidbody settings, you can change the Mass (how heavy the object is), the Drag (how much air resistance slows it down), and whether gravity affects it. A heavy object needs more force to move. An object with high drag slows down quickly. You can turn off gravity if you want an object to float.

Do not add a Rigidbody to static objects like walls or floors — they do not move, so they do not need one. Only add Rigidbodies to things that fall, roll, get pushed, or move on their own.

Testing and adjusting colliders

Press the Play button at the top of the Unity editor to enter Play mode. Your game runs, and you can test whether colliders work as expected. Walk your character into walls — do they stop, or do they pass through? Drop objects — do they fall and land on the ground, or do they fall forever? Click on interactive objects — do they respond?

If a collider is not working, the most common problems are: the collider is too small or offset from the object, the object is missing a Rigidbody when it needs one, or the collider is set to trigger when it should block (or vice versa). Stop Play mode and check the Inspector. Adjust the collider's Position and Scale until it matches the object's visible shape.

Use the Scene view to see colliders while playing. At the top right of the Scene view, click the small icon that looks like a gear or settings menu, then enable "Gizmos" or look for a collider visualization option. Now you will see green outlines around all colliders while the game runs, making it straightforward to spot gaps or misalignment.

Common collider mistakes and how to fix them

A collider that is too small will let objects pass through it. If your character walks through a wall, the wall's collider is probably smaller than the wall's visible size. Select the wall, look at the green outline in the Scene view, and increase the collider's Scale values until the outline matches the wall's edges.

An object that falls through the ground is usually missing a Rigidbody on the ground itself. The ground needs a collider (usually a Box Collider) but does not need a Rigidbody because it does not move. The falling object needs both a collider and a Rigidbody. Check that both are present and that the ground's collider is large enough to catch falling objects.

A trigger that does not work usually means the code listening for it has a typo or is not attached to the right object. Make sure the collider is set to "Is Trigger", and make sure the script that detects the trigger is on an object with a Rigidbody (even if the Rigidbody is set to not be affected by gravity).

Frequently Asked Questions

Do I need a collider on every object in my game?

No. Decorative objects that the player cannot interact with and that do not move do not need colliders. A painting on a wall, a distant mountain, or a non-interactive NPC can skip colliders. Only add colliders to objects the player can touch, that move, or that need to interact with physics.

What is the difference between a collider and a trigger?

A collider blocks movement — objects cannot pass through it. A trigger is a collider set to "Is Trigger", which detects when something enters it but does not block movement. Use colliders for solid objects like walls. Use triggers for detection zones like damage areas or pickup zones.

Can I use a mesh collider on a moving character?

You can, but it is slow. Mesh colliders are expensive for the physics engine to calculate, especially on moving objects. Use a capsule collider for characters instead — it is much faster and works well for humanoid shapes. Only use mesh colliders on moving objects if no simpler shape fits.

Why does my object jitter or shake when it collides?

This usually happens when two colliders are overlapping at the start of the game, or when the physics engine is trying to separate them every frame. Make sure colliders do not overlap in your scene. If an object is supposed to rest on another, position it so they touch but do not overlap.

How do I make a collider match a complex 3D model?

For straightforward shapes, adjust a box, sphere, or capsule collider's Position and Scale until it fits. For complex shapes, use a mesh collider, but only if the object does not move or moves rarely. For moving complex objects, consider using multiple straightforward colliders together — one box for the body, one for each arm, for example.