Is it just me or this function doesn’t seem to work as intended?
The parameters are pretty straight forward, a direction, filters, an output and a distance. However even with a pretty basic setup using two different gameobject with each their own rigidbody2d & collider2d, no hits are returned.
I placed object A at coordinate 6,0 (or less). Object B at coordinate 7,0. Both have a size of 1, they colliders match their size and are enabled. Yet, if I do a cast from object A using a Vector.right using any distance, with or without filters, it return no result at all.
Physic2D.BoxCast seem to works however… but I would prefer not having to use the alternative considering Rigidbody2d.Cast should work, and already filter out its own collider…
Ugh, the answer was right in my face and I did not realize it even though I must have read that paragraph so many time. The output is determined by the size of the array. I assume it was just a regular output parameter used for later reference, so every time I passed a null array.
“The results array will not be resized if it doesn’t contain enough elements to report all the results. The significance of this is that no memory is allocated for the results and so garbage collection performance is improved when casts are performed frequently.”
That felt completely unorthodox but it also seems like a good approach, it could explain why the out modifier wasn’t present. And I kept assuming something must have been wrong with everything else, including the environment :P.