Godot Version
Godot v4.3.stable (77dcf97d8)
Question
Hello! I am currently working on an isometric 2D game with multiple height layers. The tilemap is one main node with three TileMapLayer nodes, each representing a level of height (floor, elevation 1, elevation 2).
Through the use of Y-Sort I am able to organize the tiles properly, however I am struggling to y-sort non tilemap sprites - such as a player or cursor.
As there are multiple non-floor z-indexes, I can’t simply set the z-index of these sprites to one value, as matching elevation 1 means it will always be behind elevation 2, and elevation 2 means it will always appear above elevation 1 tiles.
I have been unable to come up with my own solution for the issue, my only potential idea is to shift the y-origin for elevation 1 and elevation 2 so they are all on the ‘floor’ of the scene (a tile ‘on top of’ floor position 3,4 would actually be in the visual grid position 2,3) - that might help with the sorting but wouldn’t help with the sprites always appearing above or below one of these elevations.
Reference Image
Let me know if there’s any additional information that would be helpful, thanks!
for tilemaps that are higher than the others just put the y-sort origin a multiple of the tilesize, depending on how much higher it is
That makes sense, but I’m still struggling to work with multiple TileMapLayers to deal with.
If the player object has a two-high tower in front of and behind it.
If the z-index matches elevation 1, then it will appear below the elevation 2 block behind it.
If the z-index matches elevation 2, then it will appear in front of the elevation 1 block in front of it.
That’s the main issue I’m dealing with at the moment.
you shouldnt use z-index for this
Genuine Question - How else would I y-sort the isometric tiles?
or it is that, if I adjust the y-sort-origin like you suggest above, then the ordering of the TileMapLayer nodes in the tree will sort that for me?
And if I do that (and all their z-indexs are 0) then would I just be able to have the player y-sort as well? (assuming I also adjust their y-sort-origin)?
yes y-sort overrides the tree-node-order, this means layers which are supposed to be higher need a higher y-sort-origin and yes the player also needs y-sort
1 Like
Awesome, I set all of them to the same z-index, adjusted the y-sort-origin, and then ordered the TileMapLayer nodes as needed - this allowed all of the tiles to be on the same y-sort z-index. Hopefully this will mean I can easily incorporate the other game objects into the y-sorting. Thank you!