doubleblind 13 Posted March 16, 2017 Hey everyone, I'm working on a set of functions to spawn a predefined composition of objects to create and man a checkpoint on a road. Several of these compositions include a static weapon or armed vehicle, but I can't get the gunner to actually be on the weapon. Compositions are defined in a config class, a relevant one is below: class hmg_pair { units[] = {"I_Soldier_F","I_Support_MG_F"}; objects[] = { {"I_HMG_01_F",288.011,4.74926,0}, {"I_Quadbike_01_F",245.906,2.31535,10}, {"RoadBarrier_F",38.6281,2.48932,0}, {"RoadBarrier_F",314.969,2.54146,0}, {"Sign_Arrow_Direction_F",119.396,1.6997,0} }; }; A function pulls data from the config entries and spawns the composition. The function is below: _location = _this select 0; _type = _this select 1; _size = _this select 2; _class = ("true" configClasses (missionConfigFile >> "compositions" >> _type >> _size)) call BIS_fnc_selectRandom; _units = getArray (_class >> "units"); _objects = getArray (_class >> "objects"); _group = createGroup independent; _center = [(markerPos _location) select 0,(markerPos _location) select 1]; _angle = (markerDir _location) + 180; _composition = []; { _type = _x select 0; _theta = (_x select 1) + _angle; _rad = _x select 2; _dir = (_x select 3) + _angle; _pos = [(_center select 0) + (_rad*(sin _theta)),(_center select 1) + (_rad*(cos _theta)),0]; _veh = createVehicle [_type,_pos,[],0,"CAN_COLLIDE"]; _veh setDir _dir; _veh setVectorUp (surfaceNormal (position _veh)); _veh setPos [(position _veh) select 0,(position _veh) select 1,0]; if ((_veh isKindOf "car") || (_veh isKindOf "armored")) then { player action ["lightOn",_veh]; _veh setVehicleLock "LOCKED"; }; if (_type != "sign_arrow_direction_f") then { _composition = _composition + [_veh]; }; // Spawning units if (_type == "sign_arrow_direction_f") then { deleteVehicle _veh; _unitType = _units select 0; _units = _units - [_unitType]; _newUnit = _group createUnit [_unitType,_pos,[],0,"NONE"]; _newUnit setDir _dir; [_newUnit,["STAND_IA"] call BIS_fnc_selectRandom,"ASIS"] call BIS_fnc_ambientAnimCombat; _newUnit unassignItem "NVGoggles_indep"; _newUnit removeItem "NVGoggles_indep"; }; } forEach _objects; // Gunner assignment is here if (count _units != 0) then { _newUnit = _group createUnit [_units select 0,_group,[],0,"NONE"]; _newUnit assignAsGunner ((nearestObjects [position _newUnit,["car","armored","static","staticWeapon"],50]) select 0); _newUnit moveInGunner ((nearestObjects [position _newUnit,["car","armored","static","staticWeapon"],50]) select 0); }; [_composition,_group,_location] spawn CH_fnc_deleteComposition; My static weapon is spawning correctly, but the gunner is spawning near the other unit and immediately moves into formation. What I want to happen is the gunner to spawn already on the static MG. Anybody got any ideas? I suppose I could use an if/then to catch any turrets or vehicles and pass them to the gunner assignment block, but I think there's got to be a more elegant solution out there. Thanks in advance! Share this post Link to post Share on other sites
HallyG 239 Posted March 16, 2017 Try using the orderGetIn command Share this post Link to post Share on other sites
doubleblind 13 Posted March 16, 2017 1 minute ago, hallyg said: Try using the orderGetIn command Changing the gunner block to: if (count _units != 0) then { _newUnit = _group createUnit [_units select 0,_group,[],0,"NONE"]; _newUnit assignAsGunner ((nearestObjects [position _newUnit,["car","armored","static","staticWeapon"],50]) select 0); [_newUnit] orderGetIn true; }; did not work, same behavior. Share this post Link to post Share on other sites
HallyG 239 Posted March 16, 2017 The nearestObjects command was returning a sign object. Change it to this: _newUnit = _group createUnit [_units select 0, _group, [], 0, "NONE"]; _newUnit moveInGunner ((nearestObjects [position _newUnit, ["car", "armored", "static", "staticWeapon"], 50]) select {(_x emptyPositions "gunner") > 0} select 0); _newUnit assignAsGunner ((nearestObjects [position _newUnit, ["car", "armored", "static", "staticWeapon"], 50]) select {(_x emptyPositions "gunner") > 0} select 0); 1 Share this post Link to post Share on other sites
doubleblind 13 Posted March 16, 2017 1 minute ago, hallyg said: The nearestObjects command was returning a sign object. Change it to this: _newUnit = _group createUnit [_units select 0, _group, [], 0, "NONE"]; _newUnit moveInGunner ((nearestObjects [position _newUnit, ["car", "armored", "static", "staticWeapon"], 50]) select {(_x emptyPositions "gunner") > 0} select 0); _newUnit assignAsGunner ((nearestObjects [position _newUnit, ["car", "armored", "static", "staticWeapon"], 50]) select {(_x emptyPositions "gunner") > 0} select 0); Bingo! Thanks a lot, hallyg. Share this post Link to post Share on other sites