OS: Mac Godot 3.5.1-stable Language GDScript

I have created a Level object as a YSort. Under it I have a ColorRect, 2 Tilemaps, a Tree Scene, and the Player.

The tree scene is composed of a StaticBody2D with a Sprite and a CollisionShape2D off it. The Sprite contains a texture from a .tres file that I made exporting 4 tiles from a tilemap to make a single object.

Both the Tree and the Player are sitting so their bottom is at (0,0). I also tried moving the Player's bottom down a few pixels.

The YSort works correctly for everything in the scene except for the Tree. The player stays behind the tree until there is one pixel between the player and the CollisionShape2D. Then it pops in front of the tree.

Any ideas on how to fix this? It doesn't happen with the bushes from the tilemap.

  • \$\begingroup\$ Please provide a minimally reproducible code example. \$\endgroup\$
    – user122973
    Feb 26 at 23:42
  • \$\begingroup\$ As my first impression, your sprites have an Alpha component that makes the depth impossible to calculate the proper order.. \$\endgroup\$
    – user122973
    Feb 26 at 23:47
  • \$\begingroup\$ When you say "so their bottom is at (0,0)" do you mean you are adjusting the Node2D->Transform->Position for the Player & the Tree scenes are each at (0,0) when you look at their values in the Inspector? \$\endgroup\$
    – Pikalek
    Feb 26 at 23:51
  • 1
    \$\begingroup\$ Does this answer your question? How to decide which Area2D is behind? \$\endgroup\$
    – Theraot
    Mar 6 at 14:35


You must log in to answer this question.

Browse other questions tagged .