Player appears in front of objects even if it's in the background

Hi,

I recently started exploring Unity but I have this weird behaviour, I have a player in Z=0 and a fence object that I want it to be in from of the player so I set Z=1, it’s a 2D game but in the 3D view I can see that the fence is actually in front of the player but in the 2D view the player is displayed in front.

Here are a couple of screenshots:

3D view, fence in front of player:

2D view, player in front of fence:

Any idea how to fix this? Thanks!

Check layer/sorting order.

1 Like

Yes, check the sorting order of the sprite. Also, as far as I’m aware, the Z position of a sprite in the 2D scene doesn’t mean anything; it’s mostly just there for visual representation of layers in the scene and for organisation. Otherwise, I don’t think Z position matters at all for sprites. I could be wrong.