I have a little problem with BoxCollider2D
. When I do this:
bool someBool = someBounds.Contains(somePoint);
I get expected result when the body has no rotation like on the picture 1. (red area is where somePoint makes someBool true) And when the body is rotated, somePoint makes someBool true everywhere inside the red area(picture 2). I don't want this kind of behaviour. I want point to return true inside the green area(picture 3).
To accomplish your goal, use BoxCollider2D.OverlapPoint
like this:
bool overlaps = myBoxCollider2D.OverlapPoint (somePoint);
The bounds
of a BoxCollider2D
assume that the object is an AABB - "axis-aligned bounding box", meaning it is not rotated and is aligned like in picture 1. So, really your pictures 1 and 2 prove this.
Source: If you go to the BoxCollider2D documentation, click on Bounds, then click on the Bounds class, you will see the details of what the bounds refer to.