OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: laggy on 25 Nov 2008, 23:40:14
-
Hello,
Does anyone have an idea how to do this:
Let's say I have a squad of 20 guys and I want an enemy "huntingteam" to follow the unit in the squad that is closest to the leader of the "huntingteam".
How can I do this in a smart way? Is there a way to find the smallest distance or number in an array or something like that?
min and max only seem to deal with 2 numbers, not more.
I know all the move commands, but not how to find the smallest number.
Laggy
-
_nearest = objNull;
_nearestDistance = 2000000000;
{
_dis = _x distance (leader huntingteam);
if (_dis < _nearestDistance) then {
_nearestDistance = _dis;
_nearest = _x;
} forEach units group
-
Thanks alot, will try it asap.
Laggy