Requested feature: Rigidbody.SweepTestNonAlloc()

(Not sure if I should post this here or in the physics forum)

While working on some project today, I noticed there was no GC-less version of Rigidbody.SweepTestAll(). Would it be possible to add a Rigidbody.SweepTestNonAlloc() that works just like Physics.RaycastNonAlloc, by passing it a pre-initialized array of RaycastHits?

Feedback page here: https://feedback.unity3d.com/suggestions/rigidbody-dot-sweeptestnonalloc

7 Likes

We also need this.

2 Likes

I think it would also make sense to offer List or IList overloads for the non-allocating physics APIs, similar to how List overloads are offered for other APIs in the engine. Right now you can miss out on some physics results if your array is too small, so you either need to over-allocate and hope you catch everything or potentially have some physics “holes”.