Jump to content
Sign in to follow this  

Spawn units looking out windows

Recommended Posts

Anyone know if it is possible (iam sure it is, but i dont know how) to spawn units in buildings (this is the easy part) at window/door positions wathing out of the window / door.. not just random facing any direction.. anyone ?? i can put down units manually and set their direction, but i want to do this dynamically (although i'am using a predefined array of buildings and positions. all i need is a way to get the units facing the right direction.

Share this post

Link to post
Share on other sites

i did manage to get my MG looking away from the building by doing this:

first i spawn my units on pre choosen locations in the building.. then i spawn the MG facing towards the center of the building.

Then i spawn in my gunner. setting his watch direction 180 degres from the MG direction (wich is turned towards the center of the building

_grp = createGroup EAST;

_buildposarray = (_buildsel select 1);

_ranbuildpos = _buildposarray select (floor(random count _buildposarray));

_buildpos = _build buildingpos _ranbuildpos;

//Spawn MG

_gunsel = _gunlist call BIS_fnc_selectRandom;

_mgun = createVehicle [_gunsel, (_buildpos), [], 0, "NONE"];

_centerpos = nearestObject [_build,(_buildsel select 0)];

_currentbuild = getpos _centerpos;

_mgun setposatl _buildpos;

_Watchdir = (([_mgun, _currentbuild] call BIS_fnc_relativeDirTo));

_mgun setDir _Watchdir;

_mgun setposatl _buildpos;

_MG = _MG + [_mgun];

//spawn Unit for MG

_mansel = _menlist call BIS_fnc_selectRandom;

_mgman = _grp createUnit [_mansel,_buildpos, [], 0, "NONE"];

_mgman moveingunner _mgun;

_mgman setFormDir ((getdir _mgun) + 180);

Credits to ghost for the orignial script (ghst_roofmgs.sqf)..

now i always get my MG facing outwards from the buildings... woorks good on Roof positions.... and note, i have to spawn each gunner as a seperate group otherwise it wont work...

Maybe someone else has had the same problem..

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