Vít Vohralík
Vít Vohralík

Reputation: 117

How to change collider in individual tile in tilemap

I am using tilemap in unity for level building. I need colliders on my tiles. If I add a tilemap collider to the tilemap it generates a collider around the tile, however I need to edit these colliders and have different colliders for every tile.

How could i do this?

Wrong collider: enter image description here

What i want to achieve: enter image description here

Upvotes: 8

Views: 27491

Answers (4)

Tiago Peres
Tiago Peres

Reputation: 15451

In your case you have square tiles and the Tilemap Collider box fits it naturaly.

To edit the Tilemap Collider, go to the Sprite Editor in the Sprite you're trying to use and modify how you want it to by clicking in Custom Physics Shape

![Sprite Editor

Then, once you have the right shape, reset your Tilemap Collider and you're good to go.

Upvotes: 26

Kalib Crone
Kalib Crone

Reputation: 117

Updated Answer for newer versions of Unity 2019+:

You now have to open the sprite sheet in the sprite editor and then select "Custom Physics Shape" under the Sprite Editor dropdown.

enter image description here

Upvotes: 0

Elliott Holmes
Elliott Holmes

Reputation: 1

I've discovered "PolygonCollider2D" which allows you to make a more precise collision shape. I've made the collisions as a separate Game object.

Upvotes: -1

Erik Overflow
Erik Overflow

Reputation: 2306

Your Sprites usually automatically generate a physics shape. You can use Unity's physics shape editor to modify your sprites generated physics shape. With this, you could modify each tile's automatically generated shape. If you're looking for a more tailored shape that is more specific than just the sprite, you may need to build custom colliders that are not tied to your painted tilemap.

Upvotes: 0

Related Questions