The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

Hey guys,

this question bugs me for a while now. I am working on a project right now and decided to deal with this when i have to, so I can focus on core-stuff for now. So I wanted to take the time to ... fully understand this matter and find the best solution until then.

Imagine you have a simple tilemap. Nothing too special, its a grass plain and you control a character. And on this grass plain your character can create small forests (in this example consisting of maybe three trees).
The forest-pattern of the trees is always the same so you decided to put the three tree-sprites into one seperate forest.tscn - scene.
What happens now, when spawning the forest is the following:

const forest_scene = preload("PATH")
[...]
var new_node = forest_scene.instance()
main_game.add_child(new_node)

Now let's assume the maingame is the node of the main scene and is a YSort-Node and the character is also a direct child of the maingame node.
The result would be that if your character moves "behind" the forest (YValue is further at the top) the character disappears behind all three tree sprites. Even if it wouldn't make sense.

What I want to ask you now is if you know any solution to this problem, so that all 4 sprites (character and the three tree sprites) can be sorted seperately, but the forest as a scene could still be used.

Maybe i am thinking of this wrong... maybe the ysort-node is not supposed to be used for this kind of problem... should I write a script that sorts all sprites on _process using the Z-Value?... Maybe one of you guys knows a trick i didn't think of by now!

Thanks in advance! :)

in Engine by (21 points)

Your forest design is then probably wrong, though I understand why you put it in a scene. You either need to separate the trees so they can be sorted independently by the YSort node, or you have to get rid of YSort and roll your own solution.

If trees are already separate objects, that could mean that the YSort node doesn't sorts nested nodes individually, and that could be the subject of an issue on Github. I didn't use that node much yet, so I can't tell which are its real limitations.

Please log in or register to answer this question.

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.