+1 vote

I have problem with ysort, I found that someone had same problem and solved with copy/paste, not working for me.

Not sorting by y axis

Interesting that if you turn ysort on, Body1 is always in front and if you turn it off Body2 is always in front.

Z is relative = true and z index = 0 for everything

Godot 3.3

Project: Project in google drive

Godot version 3.3
in Engine by (16 points)

1 Answer

+2 votes
Best answer

I looked at your project. The issue is that y position of the kinematic body node named "xianto" is actually 0.
You've moved the sprite and the collision shape but the actual kinematic body node is still at position (0,0).
The YSort node only sorts its own children and because the sprite and the collision shape are not direct children of the ysort, it'll ignore them.

To fix this, first reset the position of both the sprite and the collision shape of xianto.
The position property is under the Node2D section and part of the Transform group (in the Inspector panel). Just click on the circular arrow thing to reset it back to (0,0).

Once you're done with that, you can move the kinematic body node without selecting the children by doing one of these two:

  • Select the kinematic body node and click on the "Move Mode" button from the scene toolbar (default keyboard shortcut is "W"). Then you can move it to wherever you want.

  • Select the kinematic body node. In the scene toolbar, click on the "Make sure the object's children are not selectable". I'm not sure how to describe the icon but it's the icon to the right side of the lock node button.
    Now you can move the kinematic body node without having to worry about accidentally selecting its children.

by (180 points)
selected by

Thanks a lot, it works! Such stupid mistake :-)

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.