I've read the tutes on functions, and my function below seems like it should work, but it doesn't. Can somebody please tell me what's wrong with it?
private ["_center", "_objectList", "_lowestDist", "_i", "_max", "_object", "_dist", "_closestObject"];
_center = _this select 0;
_objectList = _this select 1;
_lowestDist = 99999;
_i = 0;
_max = count _objectList;
While {_i < _max}
Do
{
_object = nearestObject [_center, _objectList select _i];
_dist = _center distance _object;
If (_dist <= _lowestDist) Then
{
_lowestDist = _dist;
_closestObject = _object;
};
_i = _i + 1;
};
_closestObject
Thanks in advance!