Alternatives to Y-sort, or better workflow for 2D depth sorting of many objects?

Godot Version

4.6

Question

This is regarding 2D, mostly revolving around the usage of Sprite2D and Node2D+MeshInstance2D to build a world with an isometric perspective.

Each object in the world needs its depth-sorting handled carefully so that the character doesn’t “pop” behind or in front of it awkwardly.

Using Y-sort helps with this, but doing fine adjustments to the ‘anchor point’ that drives Y-sort is difficult. On Sprite2D there doesn’t seem to be a ‘set anchor point’ feature (this would adjust both the “offset” and the “position” simultaneously, allow you to adjust the anchor point without moving the object). Then when using Node2D with MeshInstance2D, we have the same problem where to adjust the anchorpoint I must first move the Node2D to the ‘y-sort anchorpoint’ location, and then apply the inverse transformation on the MeshInstance2D inside of it to bring it back to the same visual location.

I am curious if this rings any bells regarding better ways to author depth into objects - possibly using a solution other than Y-sort?

Thanks for any suggestions.

Make it a 2.5D game. Create the world as a Node3D and use Sprite3D objects that display your sprites. You can organize them and handle physics, but it’ll look like 2D isometric game without all the headaches.

You can change the pivot of a Sprite2D node by holding v while in Select Mode (1) or use the change pivot tool (2)

image

It only works with some nodes and MeshInstance2D is not one of them though.

1 Like

Very tempting, but I enjoy having more precise control over layering that 2D provides (no Z-fighting challenges), and the game art is mostly 2D. I may give up though :slight_smile:

1 Like

Wow, how did I miss that! I do wish MeshInstance2D supported an offset. My only solution is to put it under a Node2D, where that node sets the anchor point.