Home > Enterprise >  How to make one game object to be in front of another in unity
How to make one game object to be in front of another in unity

Time:12-26

I heard that game objects are drawn in the same order they appear in the Hierarchy. But in my case it doesn't work. For example I wanted the wolf is placed in front of the rabbit, but it doesn't work. Is there some way to make it with sorting objects according in hierarchy or I can make it only with layers?

enter image description here

CodePudding user response:

The hierarchy sorting you speak of only works in the canvas - so for example with RectTransforms and Images. However I guess you want to use Sprites. SpriteRenderer component has a Order in layer property. Plus Sprites are more lightweight than Images with Transparency. Or you could just move Transforms closer and further away from the camera (even if your game is 2D/ using an orthogonal camera). If everything fails you could change the RenderQueue of the Materials.

  • Related