- Home /
Sorting Layer Conflict
Hello
I am designing a topdown/isometric 2D game, that, in order to add some depth, will have the player appear on top of objects that have a greater Y position and behind objects that have a greater Y position (check image below). To do that, I switched the Transparency Sort Mode to the Y axis and have the objects' sprite points at their pivot, which normally gives the desired effect. However, I recently added a separate child "eyes" object to my player object and gave it a greater sorting order so that the eyes are always on top of the body. The problem is that to create the effect mentioned earlier, the sorting layer of both objects must be the same, which means that while the body works fine, the eyes always sit on top of other objects, ruining the desired effect:
Player behind the lockers: Player in front of the lockers:
If I change the eyes sorting layer to that of the body they don't work properly, sometimes even disappearing.
How would you go about sorting this issue? I'm a begginer in unity so I'm a bit clueless here, thanks in advance!!
Answer by Zaeran · Sep 20, 2020 at 06:32 PM
Honestly, it looks like a pretty cute effect, and I'd probably try to make it feature of the game :)
If you want to fix it though, you can probably keep existing system you have, and just put the eye pivot slightly below the player pivot to ensure its always on top of player, but close enough to the player pivot that it's likely to go behind other objects.
Ahah thanks for the tip! I thought the same when I saw him behind the closet but that's not the tone I was going for, maybe in another game :) Anyway yes that did work thanks! That was simpler than I thought, I think I was a bit thrown off by some light effects I had which were messing with how the character looked and I thought that was because of the layer sortering. But yes lowering the pivot worked, thanks!