|Topic was automatically imported from the old Question2Answer platform.
I’m trying to create an isometric game, where the character can move up and down several layers of isometric tiles.
Right now I’m using several tilemaps to represent this:
This works fine when all the “tiles” are only one layer tall, but if I want to add a sprite that’s taller than one layer, like the player character, it stops working:
As is shown in the gif, by making the two-block high sprite a child of the Tilemap layer it’s on, and enabling Ysort for that Tilemap, I can get the two-block sprite to be drawn correctly for that layer. But, for layers above it, the sprite is drawn behind all of the tiles on the above layer.
After some thinking, I’ve worked out the order I want sprites to be drawn in:
Or, in words:
With: x(Heading Southwest), y(Heading Southeast), and z(Upwards) being the Integer coordinates from the isometric perspective, and
screenY being the y position in godot's 2D space
1. Go to the z column with the highest screenY
2. draw all the sprites in that column, from lowest to highest
3. go to the z column with the next lowest screenY
4. draw all the sprites in that column
This (hopefully) draws all sprites in the correct order
##So, my questions are:##
- Is there a way to get this behavior using Tilemaps and Ysort nodes?
- If not, what is the best way to implement this in a performant way (do I set the z-index property on 2D nodes with a script? Is that too inefficient to be run every frame?)
If there are any problems with how I’ve written this question, please tell me… I’ve never used a Q&A board before
Many thanks for your help,