- Home /
[Solved] Display quad over sprites?
Hi!
I'm rather new to Unity and I'm trying to configure a scene for my game.
To get you in context: it's a platforming game, so I want my player to move, backgrounds to scroll with parallax and, in this case, everything to be behind some fog. Since it's a 2D game, I use an orthographic camera.
First I made my player and my ground from sprites.
After that, I recreated the parallax effect by making materials with my background layers and then making quads that use those materials. Then did a very little script that changes the offset of the texture according to the camera's position and the z position of the quads.
Then I tried to do something similar for my fog, attached some more quads to the main camera and made materials with my layers of fog and placed them into the scene, leaving my player and my ground between the foreground and the background quads.
Here's my scene:
My problem is that ALL of my quads seem to render behind any sprite that is not in the "Default" sorting layer no matter what Z I give to anything, so I get this:
I've been googling a lot but I just can't figure this out. I either need to decide where my quads are drawn somehow or look for another way to do the effect.
Any answer for any of the options is welcome :P
Thanks in advance!
Thank you! That was actually helpful.
For the record: when you draw all of your sprites in the "Default" sorting layer, you can use you z coordinate to deter$$anonymous$$e the rendering priority.
I believe you should be able to order anything within its layer with Z. I'm guessing layers closer to 0 get more priority.
Glad the link helped!
Answer by Eric5h5 · Jul 08, 2014 at 01:48 AM
Use renderer.sortingLayerID and renderer.sortingOrder. Feel free to use a perspective camera to do parallax, by the way, instead of having to control it with scripting. There's no requirement to use an orthographic camera for 2D.
This works too. If you have everything set up like I showed in my first screenshot and your sorting layers are kinda like these:
doing:
renderer.sortingLayerName = "Foreground";
to your quads will render them in that sorting layer.
Thank you too, Eric!
Edit: and about the perspective camera for the parallax, I will give it a try too :)
Your answer
![](https://koobas.hobune.stream/wayback/20220613153505im_/https://answers.unity.com/themes/thub/images/avi.jpg)