Does z-axis guarantee correct layer sorting in 2D?

1.3k views Asked by At

Suppose I have a lot of SpriteRenderers in the scene and I don't want to sort them by layers, but using z-axis instead: The bigger the z of the object, the further it is from the camera, therefore it should be renderer behind other objects whose z is smaller.

I tried this out with an orthographic camera and it seems to work fine, but my question is: is it guaranteed that an object with bigger z will be renderer behind an object with smaller z?

More formally: Let A and B be two objects with z-positions of ZA and ZB, respectively. If ZA < ZB, then A is necessarily in front of B?

There are no sorting layers, all objects have the same order in layer (but not necessarily the same layer). The camera is orthographic.

0

There are 0 answers