Physics2D.BoxCastAll weirdness on 5.0.1f1

After much trial and error, I’m starting to understand boxcastall. Now please don’t tell me not to use this, as I have game play logic that requires I test for a possible collision before accepting user input. Raycasting works for me, no problem, but I have a variable long shape that I need to check if it might collide with anything along its length if moved.

Here’s the problem I’m seeing: I am only getting one hit on BoxCastAll even though it should be returning every hit (which is different from BoxCast which returns the first hit). When I alter the size parameter, it will find a different hit. Shrink or expand it, and it will return a different hit, even though the new size should encompass multiple objects. So I think this is a bug in BoxCastAll.

Note, I’ve tried the BoxCastNonAlloc too, same results.

Source:

Vector2 origin = new Vector2 (-2.0f, 0.0f);
Vector2 size = new Vector2 (4.0f, 2.0f); //<CHANGING THIS SHOULD BE NETTING MORE RESULTS THAN 1
Vector2 direction = new Vector2 (0.0f, -1.0f);
float distance = 2.0f;
RaycastHit2D[ ] hits = Physics2D.BoxCastAll (origin, size, 0.0f, direction, distance);
if (hits.Length > 0) {
string message = “”;
for (int i = 0; i < hits.Length; i++) {
if (hits*.transform != null)*
message = message + (hits.Length.ToString() + ": " + hits*.collider.gameObject.name.ToString () + ", ");*
}
Debug.Log (message);
}

There’s a bug report about colliders being missed when using both Box and Circle cast methods.

All I can say is that it’s being looked at and will be resolved shortly.