Transparency Sort Axis inconsistency?

I have a gif that shows the issue, but i’ll explain it further.
I have these four sprites, with their axis set at the bottom of the sprite. In the gif you can see that i test the sorting transparency against each object, and it works fine against the couch: the sprite which has the axis closer to the bottom of the screen is rendered in front.
But this doesn’t happen to the other ones and i can’t figure out why, it behaves as if their axis are positioned somewhere else.

Anyone knows what could cause this?

That is because their axises are position somewhere else.

I briefly took a look, and from the gif it looks like your pivot point (where the sprite decides to determine its sorting order from) is the default (center of the sprite).

You need to create your own custom pivot points. Make them at the bottom, as shown in my gif’s.

Without a custom “Pivot Parent” gameobject, all sprite’s pivot point will be Center (for Transparency SortingOrder) even if you set it to bottom or something else.

To make sense of your problem, Go ahead & try changing the sprite’s pivot to center, and I bet it will all make sense after that (why the sorting order changes, when it changes). For whatever reason, Unity didn’t inform everyone that it will always be the center. They’re working right now to fix it in a future update. But I wouldn’t wait. Just implement the best practice in the link.

It is best practice in Unity2D to

have a “master parent” or ‘parent-most’ for all gameobjects. Make all the spriterenderers children. IMO, sprites should never be the parent-most gameobject; Always just children of another (even if empty) gameobject. It’s very helpful for me that way, anyway. Being able to move around that pivot yourself via gameobject (rather than via sprite editor) is better IMO, especially for complex objects. I still set the pivot in the sprite editor to bottom or a custom one (What should be bottom) so I can zero everything out & quicken my workflow, but it still helps to create gameobjects exclusively for use as a pivot.

In this way, your entity’s transform position (master parent) will be independent from the spriterenderer gameobject. Since the master parent has a size of 1, the top/bottom/sides/center are all exactly the same. Saves you with problems like this & other pivot issues.

Currently it uses the center of the sprite, not the pivot point. So it won’t matter where your pivot points are. We are adding that functionality to use the pivot point. Coming soon. :slight_smile:

3 Likes

Ooh, in hindsight just jumped to the assumption it was using the pivot without actually checking. I’m glad you guys are figuring that out, it seems to be the most intuitive way.
Thanks for the replies

Is it now possible to use the pivot points ?

Yes, it’s a setting on the Sprite Renderer. I could be wrong, but it seems to be available since Unity 2018.3.

3976003--341578--upload_2018-12-8_15-21-51.png

2 Likes

Thank you so much! I spent an hour searching why that wouldn’t work for me…

Hello! I am having a similar issue with Unity 2019.4, but actually the sorting doesn’t work at all, I’ve tried a ton of stuff, the custom axis Y doesn’t work at all, my character is either rendered in front or behind the objects and it doesn’t depend on its Y position, and I’ve set up the pivot points correctly.
I am using a tilemap

change tilemap renderer mode to individual instead of chunk

Having the same issue as @Kaldrin on 2019.4 - sorting seems to work in the scene window but not in play mode. I’m on a Mac.