0
\$\begingroup\$

As I understand it, the Z axis is responsible for the rendering position of the object in relation to the camera/other objects, and layer collision only checks if an object collides based on the x/y position.

For example;

I have a Ball on z = 5.

I have a box on z = -5.

I have the ball on a layer called "Ball".

I have the box on a layer called "Box".

As long as the check box that intersects Ball and Box is ticked in the collision manager, they will always trigger a collision regardless of the difference in their Z axis.

Is this correct? Does the layer collision manager simply ignore the Z axis in a 2D environment?

I've tried looking for documentation that more fully explains how the layer collision manager works, but I've only been able to find unity's own documentation that doesn't explain how xyz coordinates interact with layer collisions, if at all.

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Z depth can be used for parallax effects if you choose to use a perspective camera.

You can choose to use z depth for visual sorting (which object should render in front of another), and to filter potential hits for physics checks like overlaps or raycasts - providing a minimum or maximum depth range you want to consider for those queries.

Or you can also choose not to use z depth for these purposes, such as by overriding the default sort axis with a custom one. The choice is yours.

Z ordering does not affect 2D physics collisions, which happen in pure XY space.

\$\endgroup\$
1
  • \$\begingroup\$ Thank you, this fully answers my question and some! \$\endgroup\$
    – EvelynSays
    Commented Nov 23, 2021 at 14:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .