'd like to find out what the closest game object is, but not between two GameObjects, but a changing number of GameObjects. Does anyone know how to do this?
Collider closest = Physics.OverlapBox(hit.point, new Vector3(placeRange, placeRange, placeRange), Quaternion.identity);
float shortest = 100f;
float current, selected = 0;
for(int i = 0; i < closest.Length; i++){
current = Vector3.Distance(closest*.gameObject.transform.position, hit.point);*
if (current < shortest) {shortest = current; winner = i; }
}
Take your brake guys! After taking a break and coming back, I realized the problem and made this.
It looks at all the colliders and selects the shortest distanced object in a for loop.