- Home /
object always appears in front of another
This problem is really annoying and I have been at it for a couple days. I have two objects involved with this problem: a non-moving island and a player. I want the player to appear in front of the island. so I put the player in a different sorting layer. But this didn't seem to work so I tried multiple methods, including fiddling with the Z-Axis of the player, and I even changed their order within the layer, and watched the Sorting Layer tutorial. Nothing seems to be working; the island stays in front of the player! Here are the sprite renderers of the two objects, the first being the player and the second being the island. I'll comment a picture of both objects below the question. Thanks!
Answer by Creatom_Games · Jun 06, 2018 at 03:43 PM
Hey guys, I figured it out using a dumb but workable solution.
I just made an empty gameobject, put the same components as the player in it, set it to a higher layer than the island, and it worked! The problem was about the player itself and not about the island. I wish their was a better solution, and I going to do more research into this.
Answer by EXZ_EXZ · Jun 05, 2018 at 04:55 PM
Your Player just needs a higher order in the layer! For example: Green: default layer, order in layer -1, Blue: default layer, 0, and Pink: default layer, 1. All the visible objects have the same layer but with a different order.
for more information check this out: https://docs.unity3d.com/$$anonymous$$anual/Layers.html AND https://answers.unity.com/questions/726726/which-is-the-difference-between-layer-and-sorting.html
So I have already tried this method and I tried it again, still the player shows up behind the island. I set the player's order in the layer to 1 and the island's to -1. Both are in the default layer.
plz restart unity - just to be sure ... both layers and order in layer should fix your problem. In the meantime i will search for similar problems :)
plz take a look at this and compare it with your own project:
https://ibb.co/bH03yT it's an image - for some reason i couln't upload it via unity ...
Answer by koushikB · Jun 05, 2018 at 05:18 PM
Go to layers on the top right corner -> Hit Edit Layers. You'll see tags and sorting layers. You can drag each sorting layer up and down using the handle on the left.
The higher the layer is in that list , the deeper it does into the screen.
I have already done this for my layers and it doesn't seem to be working as well.
Hmm. This is weird.. Try.. 1.Having them in the same sorting layer and changing the z value. 2.Going into 3D $$anonymous$$ode and manually panning them by selecting the gameObject and pressing w. 3.Create a background sorting layer , pull it to the top , and set your islands sorting layer to background. 4.If nothing works.. I think you found a bug.