Kolmain 6 Posted April 24, 2011 Im randomly selecting a point known as _pos, then I need to check which object _pos is closest to, us_trig, ru_trig, cdf_trig, or ins_trig. For each object it is closest to, theres a differnt _fac. so if the closest object to _pos is us_trig then _fac = "USMC" and so on, if then statments tend to not work so well, maybe theres a different syntax, any ideas? Share this post Link to post Share on other sites
shuko 59 Posted April 24, 2011 Something like this? _closest = objNull; _closestdist = 100000; { if (_x distance _pos < _closestdist) then { _closest = _x; _closestdist = _x distance _pos; }; } forEach [us_trig,ru_trig,cdf_trig,ins_trig]; _fac = switch _closest do { case us_trig: {"USMC"}; case ru_trig: {"RU"}; case cdf_trig: {"CDF"}; case ins_trig: {"INS"}; }; Share this post Link to post Share on other sites
.kju 3240 Posted April 24, 2011 http://community.bistudio.com/wiki/nearestObjects If more than one object is found they will be ordered according to their distance (i.e. the closest one will be first in the array). Share this post Link to post Share on other sites
Kolmain 6 Posted April 24, 2011 @Shuko That looks great, ill try it! @PvPscene I know of the nearestObjects, but im not looking for a type, im looking for pre-placed units in an array :) Share this post Link to post Share on other sites