BEAKSBY 11 Posted August 13, 2014 HI All, How do I get all the _newUnits to be created all at once then open their parachutes once they reach the desired height, INSTEAD of waitUntil each unit one at a time OpenParachute? I think I need to create an array, then run forEach on the array but not sure how to build it in the first place? for "_i" from 0 to _NumberOfExtras-1 do { _newUnit = group player createUnit [_newUnitType, _airPos, [], 0, "FORM"]; waitUntil {position _newUnit select 2 < 55}; _newUnit addBackpack "b_parachute"; waitUntil {position _newUnit select 2 < 50}; _newUnit action ["OpenParachute", _newUnit]; }; Share this post Link to post Share on other sites
Beerkan 71 Posted August 13, 2014 } foreach units group player; is what you're looking for. However, can I ask what you're trying to do? Looks like you're trying to spawn a group of units around the player in the air, give them a parachute, and then get them to open the parachute at a predefined height. Given the speed at which the "for '_i' from 0 to __NumberOfExtras-1 " will loop at, all the units will spawn on top of each other, almost instantly, and free fall like that on top of each other. When they spawn, they will be in a standing position not in the freefall state, although may adopt that one gravity takes effect. Basically you're getting there, but I could point you towards a couple of scripts that do this already. Perhaps something you could use instead, and learn from for your own benefit. Ghost's eparadrop script. (Part of Ghost Scripts) spunFIN's HeliParadrop (Part of his AI Spawn Script Pack) cobra4v320's AI HALO Jump Script and even my own humble Simple-ParaDrop-Script Hope these help answer your question. Share this post Link to post Share on other sites
BEAKSBY 11 Posted August 14, 2014 THanks again for a the references, I went with this: //Create paratrooper group for "_i" from 0 to _NumberOfExtras-1 do{ _man1 = _men select _i; //(floor(random(count _men))); _man2 = group player createUnit [_man1, _airPos, [], 0, "NONE"]; _man2 allowDamage false; if (str(_men select _i) == str _newUnitType) then {_BP = backpack _man2}; [_man2,_openHeight] spawn{ private ["_man2","_openHeight","_para"]; _man2 = _this select 0; _openHeight = _this select 1; removeBackpack _man2; waitUntil{((getPosATL _man2)select 2)<_openHeight}; _man2 addBackpack "b_parachute"; (backpack _man2) allowDamage false; waitUntil {getPosATL _man2 select 2 < 50}; _man2 action ["OpenParachute", _man2]; }; sleep _jumpDelay; // AI Behaviour _man2 SetUnitPos "Up"; _man2 SetSpeedMode "Full"; _man2 SetCombatMode "YELLOW"; _man2 SetBehaviour "AWARE"; _man2 allowFleeing 0; }; Share this post Link to post Share on other sites