I want it to work in the general case with meshes and unions as well (so you can’t just do box-box collisions and instead you will probably have to raycast)
I saw Boxcasting/Spherecasting Request but I have no idea how that works (nor if its actually accurate) & the code is kind of hard to read
Ideally the solution isn’t to just iterate in small increments and raycast
Right now I feel like the best solution is to make a part and use GetTouchingParts() on intervals of the boxcast (or the entire distance in one go) and sort the parts to get the first
I’d use GetTouchingParts for getting all parts that partially intersect with a box or sphere volume. It saves you implementation time and for me it hasn’t been computationally expensive enough to worry about it.
It doesn’t really fit your use case though reading through the thread, since you don’t just want to know which parts are in the volume, but also ordering of closest point in the volume to the source. So in that case, you’ll need box cast.
GetTouchingParts works by tracking internal contact objects iirc; allocating and simulating contacts takes time and memory. The size of your swept shape is also beholden to part size limits.