http://www.rhymezone.com/rhymes are fun (and they get stuck in people's heads easily)
anyway, heres the problem:
i have a function in which im trying to join together a foreach and an if-then into one process, but it isn't working. the function is supposed to take an array of objects/men and a single man, and return which object/man is closest to the single man. heres the code:
private ["_potentialtargets", "_man", "_closestdistance", "_closesttarget", "_distance"];
_potentialtargets = _this select 0;
_man = _this select 1;
_closestdistance = 999999;
{
_distance = _man distance _x;
If (_distance < _closestdistance) Then
{
_closestdistance = _distance;
_closesttarget = _x;
}
Else
{
};
};
ForEach _potentialtargets;
_closesttarget
i just started making functions yesturday so i don't completely understand how they work yet. what'd i do wrong?