Aleksa Ristic Aleksa Ristic - 22 days ago 9
C# Question

Box Collider 2D using Z axis

2D means that only X an Y axis matters but when i do

OnTriggerStay2D(COllider2D col)
and do
it is fine as long as both objects stay at the same Z axis value (0, 0). When i move one of my objects to different value, they no longer collide. Why is this happening and how to fix it?

enter image description here
enter image description here

Answer Source

Objects with different Z value will not collide, as Collider2D is also 2D which lies on XY plane and the Z is same as the objects Z.
So, if you change Z of a 2D object they wont collide. Hopefully the attached image clarifies.
enter image description here
For different Z valued objects to collide, you'll need to use 3d colliders.