Ysort not working

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By kohout

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

:bust_in_silhouette: Reply From: PunchablePlushie

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.

Thanks a lot, it works! Such stupid mistake :slight_smile:

kohout | 2021-05-19 18:02

1 Like