meatball 25 Posted June 10, 2014 I'm working on a script for a mission that will iterate multiple times and dynamically create and place AI in random locations. I'm just not able to figure out how to assign those units a variable name that I can watch for triggers, etc. In a really simplified form, the script looks something like this: aiUnit = 0; while {true} do { aiUnit = aiUnit + 1; _newAI = format ["aiUnit%1",aiUnit]; _aiSpawned = _group createunit [_unitType,_position]; sleep 300; }; The question is, what's the simplest way that I can use the _newAI variable to reference the _aiSpawned unit? For example, I'd like the first unit created by the script to be able to be referenced by the variable name "aiUnit1" so I can then do things like create a trigger watching for "!alive aiUnit1". Any ideas, or is there a better way to do this? Share this post Link to post Share on other sites
Tajin 348 Posted June 10, 2014 aiUnit = 0; while {true} do { aiUnit = aiUnit + 1; _newAI = format ["aiUnit%1",aiUnit]; _aiSpawned = _group createunit [_unitType,_position]; missionNamespace setVariable [_newAI, _aiSpawned, true]; sleep 300; }; Share this post Link to post Share on other sites