1para{god-father} 105 Posted April 18, 2013 Need some help please I have marker 200x200" and I would like a continuous AI spawning once dead , but I need them to spawn in a Random direction each time and also be at a random distance out from the marker i.e 300-800m but if any Players are near say 100m try another direction. I am using UPS so they then will patrol back into the marker and start patrolling again. Any idea how i can do that ? SpawnEnemies = true; // start spawning while {SpawnEnemies} do { _Grp1 = [getPos hpad1, EAST, 3] call BIS_fnc_spawnGroup; // spawn in AI [(units _Grp1) select 0, "Base1"] execVM "ups.sqf"; // walk or run back to Marker and patrol again waitUntil {{alive _x} count (units _Grp1) == 0}; // wait until all units dead and spawn next group but at a random direction again. }; Share this post Link to post Share on other sites
mantls 2 Posted April 19, 2013 (edited) You could get a random position for the marker "hpad1" try out SpawnEnemies = true; // start spawning if (!isserver) exitwith {}; while {SpawnEnemies} do { _Grp1 = [getPos hpad1, EAST, 3] call BIS_fnc_spawnGroup; // spawn in AI [(units _Grp1) select 0, "Base1"] execVM "ups.sqf"; // walk or run back to Marker and patrol again waitUntil {{alive _x} count (units _Grp1) == 0}; // wait until all units dead and spawn next group but at a random direction again. _centerpos = (getmarkerpos "hpad1"); // sets the centerpoint _dir = random 360; // sets the direction _range = random 200; // sets the max range. If you want a min range just add it to it [ex: (random 200) + 10] "hpad1" setmarkerPos [(_centerPos select 0) + (sin _dir) * _range, (_centerPos select 1) + (cos _dir) * _range, 0]; }; I'm gonna try this out and come back to you in a bit, hope it helps. Edited April 22, 2013 by mantls Share this post Link to post Share on other sites
Nemanjic 71 Posted July 14, 2021 Is it possible to set random direction on newly spawned group/unit? It is always watching north but I need to be randomly directed because those units are guarding zone so there is no sense to guard it if I always know that if come from south it will be easy to enter unnoticed.. I tried this: myUnit = createGroup east createUnit ["O_Soldier_F", [12400,3566,8], [], 0, "NONE"]; _dir = random 360; myUnit setDir = random 360; OR: muUnit = createGroup east createUnit ["O_Soldier_F", [12400,3566,8], [], 0, "NONE"]; _dir = random 360; myUnit setDir = _dir But no work.. Thanks in advance EDIT: Or replacement for this could be if they can be set to scan horizon somehow, so view direction change all time? Share this post Link to post Share on other sites
beno_83au 1369 Posted July 14, 2021 Well, this is a hell of a necro, but at least it's relevant. So your code is wrong, some bad use of "=" where it shouldn't be. Have a look through the command reference for setDir: https://community.bistudio.com/wiki/Category:Arma_3:_Scripting_Commands 1 1 Share this post Link to post Share on other sites
Smart Games 76 Posted July 14, 2021 _myUnit = (createGroup east) createUnit ["O_Soldier_F", getpos player, [], 0, "NONE"]; _myUnit setDir (random 360); @Nemanjic just follow @beno_83au's advice next time 1 Share this post Link to post Share on other sites
Nemanjic 71 Posted July 14, 2021 Thank you guys @Smart Games @beno_83au it solves. It is hard for me to understand alone the ways code is working and write it up, but it get easier when I see final result. Thanks guys 🥤🍻 1 Share this post Link to post Share on other sites