Ok two points
- You could make a variable set it to the max value that a float can be (call it something like CurMinDistance), do this outside the loop, then compare your distance, to this CurMinDistance, if it’s less (which is why we set it to the max value, so that it is forced to be greater than any value you will get). Then just set the new CurMinDistance value with the distance you compared with. You could also update a index variable in the array to “remember” the new value that you set. Hence when you fall out of hte loop, you instantly have what you need.
If you follow this logic, you will not even need the array, nor an index into it, unless you need all 8 values for somethign later on. When you update CurMinDistance, just update a new vector variable, with the current vector, your getting the distance for.