|
It seems RaycastAll/RaycastHit provides an array of collider hits in no particular order. I'm wondering how I would go about ordering them say from innermost to outermost for a group of nested colliders? Or, more simply, just select the "outermost". Please note I have no target in mind. The outermost could be gameObject A,X,alpha,Bob,Tom, etc. I'm not looking to identify a hit by name or tag. I imagine one could test for distance to the camera (assuming the camera is outside the "outermost" collider). Wondering if there is a simpler approach. thanks
(comments are locked)
|
|
I would order them by the lowest value of Vector3.Distance(startOfRay, hit.point) On top of that, I'd just write a simple IComparable implementation so that you can just simply use yourArray.Sort(comparer) and it'll sort it in very few lines of code Thanks Mike. Very helpful.
Jun 13 '10 at 05:03 PM
pickledzebra
(comments are locked)
|
