- Home /
The question is answered, right answer was accepted
Camera shows the gameObject at the bottom cover the gameObject on top.
I have a map graphic with a white band around it (Terrain in the hierarchy center left in the attached image.). To cover the white band I put game objects over it (metalBand). However, the camera shows the Terrain over the metalBand, hence you see the white band (top right) whereas you should see the metalBand that covers it (next to that) (if I move the camera to the side, I can see the metalBand where it extends past the Terrain so I know that the camera can see it - only the order is reverse). Settings for the camera and the two game objects are in the attached image.
I played around with the camera settings but have not been able to figure out how to fix this. If anybody could point me in the right direction it will be most appreciated.
Answer by privatecontractor · Feb 02 at 09:34 PM
Hi @mjonasz,
maybe have solution for you (not the best but supposed to work...) Let's add another camera in order to being able to decide about sorting order...
Step 1: add a second camera to your scene (at some point, making GameObject "Cameras Root" and watching all cameras as children could be useful... maybe consider this also).
Step 2: create a new Object Layer that you will atache to all objects you willing to have on Top. Chose name withc you prefer like "Top Layer" etc..
Step 3 Select new created camera in hierarchy tab, and in camera preferences click Culling Mask dropdown... deselect all elements and select only your new created "Top Layer"
Step 4 Conduct almost same step on old camera, but deselect just "Top Layer"
Step 5 On new camera settings. Set depth value higher than original value.
Step 6 On new camera settings, click the Clear Flags dropdown and select Depth Only.
Hope will do, Let me know! Know it's terrible solution, but sometimes we just need push things forward. Personally using this solution for ParticleSystem and some WorldSpace Canvas Ui elements (like healthbars atached to enemy's) so belive it will help you.
Turns out the problem was the lack of a depth buffer in the render texture used by the camera - this was a $$anonymous$$i map camera.
Good job! As you manage to solve it on you own. Change your comment to answer, then: mark it as best answer.... so if anyone will have similar issue will be able to fix it.
Follow this Question
Related Questions
Getting object to show up only in MiniMap 1 Answer
How to make a character follow the cursor? 0 Answers
Switching Between Cameras JavaScript 0 Answers
Unity OSVR culling mask problem 0 Answers
Unity 5 3D Camera scrolling script not correctly placed 0 Answers