I'm trying to learn Godot and this is my fourth week now so I've decided to experiment with a project inspired by the game Don't Starve. It's a 2D Isometric game. I've converted the trees into a tileset for easy placing but if my player tries to go behind it, it appears that my player is just going up rather than going behind the tree. I've put the Player scene and the trees tileset as a child of a YSort but it still doesn't work. Take a look:

here's the link if in case you can't see the picture: https://ibb.co/dD8tNk5 It's from ImgBB.com

Now I know that this is probably because the Ysort still reads each tree as a whole sprite but is there some way I can make it so that if the player's Y position is higher than the trees' base, the trees will then load in front of the player to make it look like as if the player is behind the tree?

in Engine

this video explains all there is about the `Ysort` node(or at least all you need in order to use it)

by (1,198 points)

See my answer, I think that he wants to sort the player with the tiles of the TileMap. The video explains how to sort just sprites.

Hi! I've figured it out. check out my answer! Thank you for answering!

What we achieve placing both the `TileMap` and player as direct children of `Ysort` is that when the player Y position is higher than the tilemap Y position, our player is drawn above the tiles, but this is using the "general" `TileMap` Y position value, not the individual tiles Y value.

What I understand you (and also me) want to achieve is sorting our player along with the tiles of a `TileMap`. In version 3.1, there's a "Y Sort" option on the `TileMap`, but it (again) just acts as an YSort, sorting only the direct children of the tilemap (not its tiles).

I think that a solution is to place the tiles manually as a sprite as a child of `Ysort`, but that is defying the purpose of `TileMap` I think.

by (18 points)

Hi! I've figured it out. check out my answer! Thank you for answering!