In my scene there are two GameObjects. Both with a BoxCollider2D. The left one has a script attached which uses the Physics2D.OverlapArea method to find collisions between the two objects.
As parameter of the method I use the values of bounds of the BoxCollider2D. I log the maximum X of the collider (the right edge). If there is a collision I also log the minimum X (the left edge) of the other collider.
You can see in the log that there is an overlapping recognized with an X-value of the right edge of the left object smaller than the left edge of the right object. How is that possible? The two colliders should not overlap.
In the screenshot you can see the small gap.
The overlapping code:
void Update() {
Collider2D result = Physics2D.OverlapArea(collider2D.bounds.min, collider2D.bounds.max, collidingLayer);
Debug.Log("Player maxX: " + collider2D.bounds.max.x);
if (result != null) {
Debug.Log("Block minX: " + result.bounds.min.x);
}
}