Draw Sorting Dependent on Whether sprite is above or below other sprite

Godot Version

4.2

Question

Hi there, I’m pretty new to Godot and I learn best by doing rather than reading so apologies if this is something super obvious - I am working on a 2D topdown RPG and am creating the illusion of depth by having collision boxes on NPC sprites which are smaller than the sprites they are attached to, this allows the player to go “behind” the top of the object. However, because the draw layer is consistent for the entire object, the player’s head will be obscured by the bottom if they approach it from the bottom. My desired effect would be to have the player’s head in front of the bottom of the object. Is there a way to make it so the player will be drawn above the object if approaching from the bottom and beneath the object if approaching from the top? I know I could simply split every sprite object into two sprite objects under the same parent, with each one representing each vertical half, but that seems like an extremely unscalable solution so wondering if there is a simple way to achieve this but couldn’t find anything. Much appreciated.

assuming you are using sprite2d or Node2D inherited class node, it should be handled well with y-sorting

1 Like

Thanks, was simple enough but I wasn’t implementing it properly - appreciate it

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.