Hey, so i am making my first ever 2d top down game. First ever game for that matter. Anyways, i have a sprite for my player with a sprite renderer, and a sprite for my ground with a sprite renderer. ( all the renderers do have sprites with them ). So what i need help with, is that my player sprite when i drag it goes behind my ground sprite to where i can’t see the player sprite. Is there a way to fix this? If so please reply with an answer.
On the SpriteRenderer component, there’s something called “Order in Layer” under “Additional Settings,” this controls what renders above what.
Change your player to have a higher Order in Layer than the ground to see the player in front of the ground. They have to be on the same sorting layer for this to work. “Sorting Layer” is right above “Order in Layer.”
You could also create a new “Sorting Layer” for the ground or player. Click on “Layers” at the top right of the Unity window → Edit Layers… → Unfold Sorting Layers and click the plus.
Layers lower on the list will appear in front.
That’s not exactly true. Simple explanation:
If they are on the same sorting layer. The one on top is the one which has a higher sorting order.
If they are on different sorting layers. then the one with the higher sorting layer is on top.
Also for a 2D topdown game. You should check out transparency sort axis. Before you start assigning loads of different sorting layers and orders. It can sort your sprites by Y axis. So if you have two sprites(same sorting layer and order) the one on top will be the one that has a lower Y axis. Very useful for player/ enemies/ game objects like trees rocks and what not.
It is exactly true, Order in Layer doesn’t affect anything for sprites on different Sorting Layers (because the Sorting Layers will decide the render order in that case); that’s what I was saying. I was trying to explain that as clearly as I could, but I guess I failed. If he understands your explanation better, then that’s great.
This is good advice, but for a beginner who doesn’t know anything about sprite render order at all, I figured I would start with the basics.