+1 vote

I'm currently playing around with the isometric tilemap in Godot.

I can define a tile easily and everything looks right, but when my character moves towards a wall "above" them, they display beneath it:
enter image description here

I could fix this by changing the order of the scene tree, but then the sprite would display above the walls "below" them, instead of acting properly as they do ATM.

I know it's possible to have the sprite display "on top" of the walls above and "beneath" the walls below, as that's what is seen in the demo, but I'm not sure how to do that. Any help?

EDIT: OK, I've realized that if I put my character node as a child of the "Walls" node, it works, but I have no idea why. An explanation would be greatly appreciated

Godot version Stable
in Engine by (22 points)

1 Answer

+2 votes
Best answer

Tilemap in demo uses YSort (Cell/YSort is enabled). YSort is sorting by y-position of nodes. Nodes with higher Y values are drawn last, so it looks like they are upfront. Putting your hero inside Walls node forces him to be Y-sorted too. Note that it only works for direct ascendants of YSort values (if you need to save y-sort for descendant of added nodes you need to make their parent YSort node to save sorting order).

Here's one of the tutorials explaining how to do YSort and how it works https://www.youtube.com/watch?v=jK7ebPIq1Ho. Or you can watch any YSort tutorials to understand how it works.

by (1,370 points)
selected by
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 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 webmaster@godotengine.org with your username.