2D character walking around objects?

I’m trying to decorate my 2D world with 2D objects, and I want the player to be able to walk “around” the objects, so that the character can stand in front of the object, collide with it and walk behind it. I’ve achieved the effect in some way, but when you move the character down from the top part of the object, it clips on top of it. (See the pictures: )
The characters appears in the front of the object as she should:
5267751--527208--Collidea.png
The character can also go behind the object at the upper part of Y-axis…
5267751--527211--collideb.png
…but when she walks down, she clips on the top!
5267751--527214--collidec.png

I tried to look up multiple threads and a couple of videos on how to achieve this effect, and they all seemed to use a line of code. However, when I looked at the newest comments, they all said that you don’t need the code, since Unity already has a built-in way to do it (Graphics settings > Transparency sort mode), so maybe the tutorials were just outdated. Still, I’ve been trying to mess around with the order of sorting layers, pivot points and transparency sort mode settings, but nothing seems to help.

(Currently, I have both the house and the playable character in the same sorting layer, their pivot is set to bottom and transparency sort axis Y is 1)

Is the SpriteRenderer for the house using “Pivot” for the “Sprite Sort Point”?

Also, the pivot for the house should probably be where the back of the house would meet the ground, some distance up from the bottom, because the character would only be “behind” the house when it is above that Y position.

Also make sure your transparency sort mode is set to CustomAxis in order to actually use the custom axis.

1 Like

Got it, the problem was that the Sprite sort point wasn’t set to pivot.
One click would’ve fixed the problem I tried to solve for days :roll_eyes:

1 Like