• 2D
  • How to use Y-Sort for isometric Tilemaps

Hi, I'm working on a Minigolf game that uses a single Tilemap Node for the map, and I am trying to get the player ball to be drawn behind walls. Currently, it looks like this:

When I use the Tilemap's YSort or a YSort Node, the grass is clipping in front of the ball:

YSort mostly works for walls (still not perfect)...

...but not for grass

The tiles would need these z-indexes, but I haven't found a way to implement this with multiple Tilemaps, because the z-index would need to change dynamically (like in the picture walls are could be in z 1 or in z 4 and there are more balls, so it gets even more complex).

But I can't even write that logic because as far as I know, Tilemaps don't support tile specific z values. So I tried using Scenes for Tiles, which would allow me to use logic from code for Z-Indexing, but the performance is a problem. A small map would already need ~300 Sprite Nodes and even without scripting anything for them yet the fps dropped to <10.

The only other solution I can think of right now would be to find a way to set the tileset origin for example to the center and on the height of the left and right corner I think it would work. But the options are limited to center, top left and bottom right...

I am not familiar with shaders, but maybe they could do something like that. Hopefully there is a simpler way.

I don't know if this is relevant, but all tiles in the tileset have a texture offset of -10y to make them appear at the correct position:

Without offset

With offset

There must be a way to do this, right? Any help is appreciated :)

The Easiest Solution I see is to duplicate the Tile Map and use a diferent Tile Map for the Grass. That way you can activate Y sort for the walls and keep the grass alway behind the ball.

Yeah, you can have as many tilemaps as you want. Typically the ground is it's own tilemap, and then the wall or structures are a separate tilemap.