+3 votes

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:

The player looks like he climbed on the tree

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 by (104 points)

3 Answers

+2 votes


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

by (1,204 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!

+2 votes

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!

+2 votes

I've figured it out. After looking at the isometric game demo of Godot engine, instead of putting the ground tilemap, trees tilemap, and the player under the child of the YSort, I removed the YSort, and I've put the player as a child of the trees tilemap instead and enabled its Ysort property.

by (104 points)

i know this is necroposting, but adding the player (kinematic body in my case) as a child of the tilemap doesn't work. The player will still walk over the tilemap regardless of its Y position.

I find the same thing. Not sure how to fix it.

Play with the tile origin a little, that helped me.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.