Add colliders to your 2D tilemap in Unity

Daniel Kirwan
2 min readAug 30, 2021

Objective: Add in some colliders to a 2D tilemap in Unity

So, you’ve painted in your scene and added in a player character but they keep falling through the world. You need a tilemap collider.

On the tilemap object in the hierarchy, add a component of Tilemap Collider 2D. This will add a collider to all of the different tiles painted onto that tilemap as shown above.

What you can do is have it so only the surface tiles have colliders on them.

To do this, you need to add another component called Composite Collider 2D. This will automatically add a rigid body 2D component that it also needs. In the Rigid body 2D component you need to change the body type to static, then in the Tilemap Collider 2D component, change the used by composite attributes to true.

You will now see that the tilemap that you’re adding the components to, will now have a collider, but it will only be on the surface areas of the tiles and not the ones in between.

--

--