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” How can I display a flat background - 2D image, not a skybox - behind everything in my camera? - Unity Answers 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

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.