Rotated parent GOs make sub GOs relative draw layer wrong?

Hello!

I think the issue boils down to how draw order is calculated inside the engine; based on Z position for the component. I tried to draw an image to explain it as simple as I can for this situation:

  1. First image shows a basic setup of 3 gameobjects+sprites, shown sideways here to illustrate how they “layer” on top of each other. (They all have a different Z position indicated by the spacing between them.)
  2. The second image show you the same setup from above, Z axis pointing towards the eye/camera. Here the draw order is as expected, back to front; A, B, C.
  3. In the third image, the parent object has been rotated by 45 degrees. This means each gameobject (indicated by the small red/black dot/cross) will have a different world position than before… Now focus just on the Z value, which is used by the engine to determine in what order the gameobjects/components should be drawn. As you can see the Z value for C is less than both A and B, meaning it will be drawn first.

Sorry for the quick and dirty image, but hopefully it clears up some confusion. :slight_smile:

But back to actually trying to solve your issue… We discussed a couple of different approaches , but I think the quickest way might be to do something similar to what I described in this post: The label component blink when rotation GO over Y axes (SOLVED) - #4 by sven

It should work for orthographic projection as well, as far as I know.

3 Likes