Godot, Is there any sorting group for sprites?

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

I’m learning how to animate 2d skeleton, when I try to put my characters next to each other, those sprites are going through each other
I’m new in Godot and I don’t know how to use it properly.

I used to work with Unity, but since I heard about Godot, I loved it want to know it very good but I don’t know how to use it.

I checked Ysort node but it didn’t help me.

Please help me.

Here are my scenes.

I am new in godot… little time ago I came to this issue as well, I was suprised that Y-Sort has no priority over z-index as I thought it should have. Reading the google I found I am supposed to override Y-Sort by creating custom sort method. Easiest way imo is adding 100 * most_top_sprite_parent.position.y to z-index of every sprite part (so robot one would have z-indexes 100, 101, 102; and robot 2 eg. 400, 401, 402 and so on). But I haven’t go this way. I redesigned the concept of the creation I was making. Also there is an option to “relative” z-index, play with it too… but really, I am newbie here, I have no straight answer.

Reloecc | 2020-09-12 14:52

1 Like
:bust_in_silhouette: Reply From: sinistro25

In the inspector on Node2D you can set the Z index. The sprites are rendered in increasing z index, so a sprite is drawn over the sprites with lower z index.

This might not be the cleanest solution as I’m not sure what is causing your issue.

But exactly this is the Problem.

you create one Object called fruitplate containing two sprites:
Apple, on Z-Index 0
Banana on Z Index 1.

Great, now the banana is always on top of the apple, just as you suggested.

Now duplicate the "fruitplate " and the banana of both objects are always on top.

How can you achieve that one “fruitplate” is on top of the other?

Unity solves it with Sorting groups, how can you do that in godot?

when working with complex charactermodels that are not just pixel art, this problem will occur, and I just can’t believe that putting them all in a viewport to fix that issue is the only solution

1 Like