How to Create Custom Colliders for Individual Tiles in Tilemaps

So I’m working on a top down game where the character will be moving on top of the Tilemap. An example of a basic scene Tilemap is shown below:

I need to be able to add colliders to specific tiles that have walls on them.

For instance this above tile needs a collider on the wall portion (where the red follows would be the collider shape), but not on the brick floor portion because the player will be walking on that part. I can’t seem to figure out how to go about implementing this custom collider shape however. Modifying the sprite outline to only contain the wall part actually prevents the part of the sprite not contained in the outline from rendering, so that’s clearly not the right solution.

1 Like

If I understand correctly, inspect the image.
Tick Generate Physics Shape.
Click the Sprite Editor button.
Change the dropdown in the upper left from Sprite Editor to Custom Physics Shape.
Click Generate. This will do a fair job of wrapping the collider edges around the sprite.
Fiddle with the vertices to get it the way you want, then click Apply.

11 Likes

Okay, it looks like that is working correctly. Now I’m curious how I would go about specifying the center tiles to have no Physics Shape / Collider at all. Simply creating a custom physics shape and then deleting all vertices of the generated polygon doesn’t seem to work.

Try unticking Generate Physics Shape, and make sure your tilemap renderer’s mode is Individual.

If you uncheck the box “physical shape” should all work.

This was the perfect solution thanks a lot!!

1 Like