Isometric Tilemap Overlay [RESOLVED]

Hi,

I’m currently making a 2.5D game with unity with the following asset pack as placeholder.

Currently, I have multiple isometric tilemaps (Z as Y) :

  • one for the terrain (height / biome / …)
  • one for each overlay (grass, bricks, snow, …)

If I set each tilemap to the same sorting order/layer, overlays at the same elevation won’t be shown, but if I set the tilemaps to a different sorting order/layer, then the overlays will be drawn above more elevated tiles (see screenshot bellow).

What would be the best practice here?

Thank you.

Is there a reason you’re using multiple tilemaps here? If you have a Z as Y tilemap, you can have all your tiles in one map. For standard tilemaps it makes some sense to have different tilemaps, but for a Z as Y, your ordering is linked to the position in the tilemap and isometric tiles need a degree of overlap, which only the single tilemap can handle properly, so it doesn’t make sense to try and separate them usually. You might as well have everything in the one tilemap that is a tile just with the appropriate Z adjustments.

According to the documentation, the Tilemap.SetTile method takes integers for the coordinates.

If I increase the Z coordinate of my overlay, it will be displayed as a more elevated tile, which is not what I want.
If I don’t adjust the Z coordinate, then the underlying tile will be overwritten by the overlay, which is not what I want either.
It’s not like I can use 1.0001 as Z value, since it requires integers.

Therefore, the only solution to use only one Tilemap would be to have the tile sprite for every possible combination of “base tile + overlays”. Let say I have 10 base tiles, and 5 overlays (a tile can have 0 to 5 overlays), that would be 10*5! = 1200 sprites to prepare.

Am I missing something?

I think you’re thinking about the tiles wrong here. It seems like you’re trying to mix flat tiles with cube tile and getting confused. For instance, you seem to want to have dirt ground which is a cube like one with grass on top but it is flat. Your dirt ground would be at Z 0 and your grass would be at z 2. You just have to be sure that your grass is at the bottom of its tile, as if it was the bottom of a cube because in the end your tiles are cubes, whether they look like it or not.

Here is an example of base tile and the following overlays I’m trying to apply:

As you can see, all assets are of the same size.

I get that placing the grass flat tiles at the bottom instead of the top and using a different elevation would work. But for the last one, it would not.

I guess I have to create a custom shader, to use with the TileMap Renderer material, which would apply the overlay textures to the base tile.

Well, it brings opportunities, like animating the tile or dynamic lightning, which could be cool.

Thank you for your insights!

6705256--770173--ISO_Tile_Sand_01.png
6705256--770176--ISO_Overlay_Grass_01.png
6705256--770179--ISO_Overlay_Grass_Patch_03.png
6705256--770182--ISO_Overlay_StonePieces_01.png

If decide against the shader, another thing to try would be changing the tileData.transform via tilemap.SetTransformMatrix(cell, matrix). This would allow you to have two parallel tilemaps. When setting a tile, you’d set both the base and overlay. Then, for the overlay, you adjust the tileData.transform very slightly so it sorts correctly.

You can test if this would work for you by placing tiles on the two tilemaps, and clicking on the overlay tilemap cell. This will bring up the Grid Selection Inspector, which allows you to adjust the transform. If you can make it sort to your satisfaction, then it may work.