New User: Heirarchy question

Hello, I’m brand new to Unity here, I have some experience tinkering in Construct and other programs but I’m really enjoying the depth of this program so far. I’m going through the Bolt tutorial on the Unity site, and I’ve uploaded all of the assets, but the problem I’m running into is that the background is wedged between some assets, and I don’t know how whether to adjust the hierarchy window or the layer menu in the inspector so that I can make the background as in-the-back as possible.
As it stands the PC is in front and a couple of other random prefabs, but the platforms are behind the BG, and it’s driving me nuts!
If anyone could help it would be greatly appreciated. Thank you :slight_smile:

First thing, the hierarchy only matters in so much as parent child relationships. Everything else is just for your own development reasoning, not for actual gameplay reasoning. In other words if you have two objects A and B in that order in the hierarchy, there is no guarantees about which order they will actually process by just their position in the hierarchy. A could process first then B (leaving B seeming to be on top) or B could process first then A (now putting A seemingly on top). You just don’t know as Unity optimizer will decide how to do things. Everything could look fine for a long while then suddenly a change to the project that shouldn’t affect anything will cause unity to alter the processing order and suddenly things are reversed. So never rely on it to process in a certain order due to the hierarchy ordering. This same lack of guarantee likewise applies to the order in which awake, start and update routines are called btw. Again parent child relationships are different and actually do matter.

So, if you actually want to guarantee an order of sorting their are four methods:

  1. change the sorting layer of the object
  2. change the order in layer of the object
  3. change the z position of the object
  4. change your project settings to have a custom sorting axis so that some other properly of the position affects sorting (most often the y coordinate).

For 1 you can make up your own set of sorting layers, and the editor UI allows you to even change their ordering. Access this editing feature up top using the layers drop down. Do note their are 3 types of layers: Tags, Sorting layers, and just Layers. Sorting Layers is the one you’re interested in here (layers is for things like deciding collisions and honestly never used tags so not sure on its purpose).
For 2 it is simply an int that decides the order in the layer so set a higher one if you want an object to come out on top.
For 3 it is similar but does depend on your camera position and setting for what effect it will have.
For 4 this is mostly used for tilemapped games like a zelda clone where you want the characters to move behind objects as they move. This one to get right can be pretty complicated, especially for isometric games.

Great, thank you for your response! I will look into this, I really appreciate your help.