I can very easily create the collision I want for each tile with a simple box collider, but I don’t see how I can apply that collision to specific tiles in my tilemap.
I could even make do with assigning a custom collider to every tile on my map, and then using different maps for the different collision shapes I need. But I can’t even see how to do that.
Have you tried in your tile script settings ColliderType to Grid? tileData.colliderType = Tile.ColliderType.Grid;
So, you could have a custom tile that you paint grid-collider to sections of your tilemap.
That is an improvement; now I can have a pure square instead of whatever wonky shape it tries to fit around my image.
But is there any way to create custom colliders? Like if I wanted to use a box collider with specific dimensions, or draw my own polygon collider?
What happens with you use ColliderType.Sprite in combination with a Composite Collider? It should combine your custom-defined SpriteOutlines (defined w/in SpriteEditor) into combined polygons.
The Custom Physics Shape of a Sprite applies to the TilemapCollider2D if the Tile has the same Sprite and is using the ColliderType.Sprite. This allows you to set a specific Physics Shape for a particular Sprite.
I know this thread is done at this point, but I thought I should mention this on behalf of anyone who comes across this thread in the future, facing the same problem.
I didn’t realize this was a thing, so I’m going to go over this very explicitly for anyone else who doesn’t know about it.
If you go into the Sprite Editor (select the actual image containing your tile, and there will be a “sprite editor” button in the inspector,) in the upper-left corner there is a drop-down box that says “Sprite editor,” if you change that to “custom physics shape” then the editor window will let you create any polygon shape you want for an individual tile. (You have to select a tile and click “generate” before there is anything the edit, though.) And it has a VERY nice snapping option that makes it super-easy to make perfectly flat and uniform shapes.
This will be the shape a tile uses if you set the tile to “sprite,” which it does by default.
I got lost originally because I was trying to edit the settings of the “tile” data that gets generated when you add a tile to a tilemap palette. I had no idea that I needed to adjust this through the sprite editor.
This is actually the very first thing that was suggested in this thread, but I didn’t realize that it impacted the shape tiles would use in the tilemap.