UPDATE:
{
I finally solved the problem. Thank you all for helping me.
I still have no idea why it was doing the stuff I mentioned at the beginning, which was the reason why I opened this thread. But now everything works fine. Please, see the solution at the end of this first post or at the end of the thread (the big paragraph I wrote).
Hello. I am doing the Ruby’s Adventure tutorial.
I found a graphic problem and I have no idea about how to fix it. The problem is: when I move the character against an object (a box), character’s sprite overlaps box’s sprite just for a moment after colliding. Like in the next gif I made:

If the character is next to the object (with no space between remaining), and you try to move it, this doesn’t happen. So, the character has to move some space before colliding to make this happen.
If the character moves but doesn’t collide with the object, it doesn’t overlap box’s sprite either (see the gif below). But when it collides, even moving slowly, the graphic error happens again.

The only exception is when you move a little each time, pressing fast and quick the key to move (like trying to move pixel by pixel). This way you finally collide with the box, but there’s no overlaping. This makes me think that maybe speed has something to do with the issue.
(EDIT: I want the character to hide a little bit behind the box, the problem is not that it gets behind the box)
Details:
These are the collider boxes for both objects:

These are the settings I am using for the Graphics (following the tutorial), so Unity calculates which sprite should appear on top:

Transparency Sort Mode: Custom Axis
Transparency Sort Axis: x=0 y=1 z=0
Also, character prefab has “Sprite sort point” setted as “Pivot”.
Box’s sprite has “pivot” at “bottom”. Character’s sprite has “pivot” as custom (but also put at bottom in the editor).
As I said, I have no idea about how to fix this problem. Please, can anyone tell me why is this happening and help me to fix this?
Thank you very much.
UPDATE: THE SOLUTION ![]()
![]()
![]()
Well, after changing the box collider increasing it’s height, I found that the character keep rendering on top and not hiding. I cound’t get the same problem as I mentioned in first place (rendering on top a little then hidding behind the box).
Anyway, the solution is the next one:
If you want the character to hide a lot behind the box as I did, when the character passes half the height of the box sprite, it is rendered on top. You should change the box prefab and set its “Sprite sort point” to “Pivot” (box sprite should have its pivot in bottom). This way, the character will not be rendered on top (unless it passes the bottom pivot, which is impossible due to the collider).
If you want to keep the sprite sort point of the box prefab as “Center” instead of “Pivot” (for any reason), you just need to adjust the collider to be tall enough to pass half the height of the box sprite, so the character will not pass that point and Unity will not render the character on top (as Unity uses that point to calculate which thing goes on top).





