- Home /
Static background image, camera follow player
Hi,
I'm relatively new to Unity and trying to work with some 2D examples. At the moment I'm working on an infinite runner example whereby the main camera follows my player. To make the game more interesting however, I want to set a static background. Now I have searched the forum and I know the usual answer is "this has already been answered, go here" http://answers.unity3d.com/questions/9729/how-can-i-display-a-flat-background-2d-image-not-a.html and believe me, I've tried the steps outlined in that a number of times, but my background image seems to render above my player.
All my cameras are on the "default" layer, and they currently both have the same z position of -10 (not sure if this is the issue, but I have tried changing these settings so they are on different z positions and on different layers but nothing seems to work) All the other settings seem to be correct as per the linked post. So can anyone suggest to me here what might be wrong? At the moment my player is just a default Sphere gameObject so I thought it might be lighting, but adding a sprite doesn't make any difference.
Thanks
Answer by rutter · Feb 05, 2014 at 11:40 PM
When rendering multiple cameras, it's very important to set appropriate clear flags, culling mask, and depth.
Many setups render the "main" scene camera, first, before rendering additional passes over it, but in your case it sounds like it'll be rendering over the background. Keep that in mind when reading tutorials on multi-cam setups.
Clear flags tell a camera which sorts of information it should discard from the previously rendered frame. Cameras rendering over one another usually clear the depth buffer.
Culling mask tells a camera which layer(s) of GameObjects it should render. If there's any chance your cameras will ever see each other's scene objects, make sure they're rendering appropriate layers.
Depth controls the order in which your cameras are rendered (smaller values go first).
Finally, why not use a skybox? They're so easy.
Thanks for this. Is wasn't aware of the SkyBox. Everything I'd searched for up to this point suggested the previous approach! It's one of those cases where you don't know what you don't know!
Your answer
![](https://koobas.hobune.stream/wayback/20220613132637im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Dynamically setting sprite frames through code - Unity 2D 4.3 0 Answers
(Video link) 2d sidescroll runner, objects become blurry with speed. 3 Answers
How can I make my "Squat" button register with just a press? 1 Answer
I don't know how to ground check the player 3 Answers
Button doesn't react properly 0 Answers