Jump to content
Sign in to follow this  

help with a forEach command

Recommended Posts

Hello all,


I was hoping for some advice on an issue I am having. I am creating some blufor units to send into battle, and can create and move them to the first objective fine. I am also keeping them at said location for a bit while they fight off attackers. When the attack waves have completed, I am also changing the colour of the marker I created to make it easy to see where the action is. 


My issue is getting the units to move to another location.


This is what I used to create the units:



if (_point0) then {


    for [{_x=1},{_x<=20},{_x=_x+1}] do


            bluGroup = createGroup west;

            _pos = [_bluStartPos, 0, 30] call BIS_fnc_findSafePos;

            _unit = bluGroup createUnit ["B_Soldier_F", _pos, [], 0.1, "none"];

            sleep 1;

            _unit setUnitPos "AUTO";

            _randomDir = selectRandom [270, 310, 00, 50, 90];

            _randomDist = selectRandom [20, 22, 24, 26, 28, 30];

            _endPoint1 = _point1 getPos [_randomDist,_randomDir];

            _unit doMove _endPoint1;


    _point1attack = true;

    _point0 = false;



I have some conditions running which help to manage mission progression.  The condition in question to trigger continuation of the mission is _point1attack = true, and this is applied when all point1 enemies are killed.  My assumption was that I needed a forEach command, but this (and variations of this) did not work:



if (_point2attack) then {

            _x doMove _point2;

        } forEach allUnits;

// _point2 = randomly created array of two numbers, i.e. a position


If anyone could steer me right on this I would be very grateful.. apologies for missing what is probably a very obvious error here...





Share this post

Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now
Sign in to follow this