what i have is an array of possible spawn points, id like to get the one point which is furthest from enemy units.... so players don't spawn directly on top of enemy players. please halppp! :P
Loop through the array, constantly remembering two values. Distance from the target, and which index that distance was at. Whenever you loop over a distance greater than the one you were remembering, remember the new distance and the index it was at.
When you exit the loop you'll have the point that's the furthest away
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
hey guys,
what i have is an array of possible spawn points, id like to get the one point which is furthest from enemy units.... so players don't spawn directly on top of enemy players. please halppp! :P
thanks :D
Loop through the array, constantly remembering two values. Distance from the target, and which index that distance was at. Whenever you loop over a distance greater than the one you were remembering, remember the new distance and the index it was at.
When you exit the loop you'll have the point that's the furthest away