Having trouble adding background image to my game

This is only loosely tied to the Laser Defender game.

I’ve decided to use my LaserDefender game as the basis for a new game, and as such I need to add a background image to the play field.
I found an appropriate image, added it to the game, but no matter what Z position I set it at, its always over my player character. (I moved it up so its only covering half of it to show it.

Right now my Player Z Pos is 1, and my Image Z pos is 30.

Any ideas?

Forgot to show the inspector for the image object.

I am wracking my brains for you right now, because I had something similar with a scroller game… there were two images being used for the star field, the scrolled down and respawned at the top to give the illusion of the player moving. The player character would go over one but then under the other! It’s obviously not the exact issue but I wonder if what ever I did to resolve that may resolve this for you.

What’s the camera mode set to?

The order of items in the hierarchy is ringing bells actually… I seem to remember there was a separate hidden layering value… sorry this is vague… try moving the Player object in your hierarchy to above the background…

1 Like

Yeah, I’ve tried adjusting Z positions of both objects, changing their positions in the hierarchy, even deleting and reading the player prefab.

Heres the camera inspector.

What’s the render mode on the canvas set to Chris?

Also, when you set the Z on the Player, was that on the Prefab on the game object?

Gunna see if I can load up the mini game I had the problem on to see if I can recreate it…

Order in hierarchy was one thing and also “order in layer” for the sprite … I’ve just dug out the info from the Facebook post… I can’t find a way to link to the specific post though… but if you go to the Unity Course Facebook page and search in there for “Rob Meade layering” my post is the second one down (15 April), pretty sure the info from those replies resolved my issues at the time.

Search Link

1 Like

@chris.claus42, I think that the problem is with the canvas render mode, since it might be on the Overlay mode.
Try adding another Canvas with render mode set to Camera (choose the main camera as target), put the background in that canvas alone, and set that canvas Z position behind everything else, it should solve it.

Canvas Render Mode is Screen Space Overlay.
Changing it to Camera doesnt seem to do anything, and changing it to World Space makes the image disappear.

I tried what it said in your facebook post Rob, but it didn’t seem to help.

i just tried that Joao, and it didnt seem to do it either.

Heres my current layout, in the scene tab the camera on the left, ship in the middle, and canvas on the right.
Changing layers and rendering layers and all that didnt do it.

1 Like

strange, I had this exact same problem yesterday night.
Overlay Canvas will always be rendered in top of the Scene, do all tests with it under Camera Mode and with Z below the player.

Perhaps the problem is with the sorting layer, the player might be on a sorting layer (under Sprite Renderer) above the default UI Sorting Layer, have you tried putting the canvas at the same sorting layer(Player) or at a sorting layer above?

1 Like

I feel like a total moron now.

It was sorting layers, and the camera not being attached to the canvas. I just had them backwards. :sweat:

Thanks for all your help!


I’m glat that it was solved!
Don’t worry, it’s a regular kind of problem :+1:

1 Like

Yay! Glad this is fixed… I think the sorting layers were mentioned in that Facebook post by Ben Pearson, but obviously I don’t think the issue mapped exactly to yours…

So… more important question - when can I play your shooter Chris :slight_smile:

1 Like

Once I have a working playable demo available, I’ll let you know.


Looking forward to play it too chris!!

1 Like