'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



Solution 1:[1]

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.

Solution 2:[2]

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

Solution 3:[3]

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.

Solution 4:[4]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Kalib Crone
Solution 3 Erik Overflow
Solution 4 Elliott Holmes