Hi there,
There are polygon colliders on different objects that overlap with each other. I need to retrieve the polygon collider from a specific object only. To achieve this, I have assigned a unique z-coordinate to each object. However, the script I’m using does not consistently return the expected collider:
Collider2D collider = Physics2D.OverlapCircle(worldSpawnPos, 0.35f, polygonColLayer, (zCoordinate - 1), (zCoordinate + 1));
When I remove minDepth and maxDepth, the results are as expected, but it includes colliders from all objects.
Is there anything else I need to know about minDepth and maxDepth? What could be the possible reasons for this problem?
Edit: I was doing something wrong, otherwise the code is working as expected.