Jump to content
Sign in to follow this  
Tejkr

Unit get in vehicle script

Recommended Posts

Hello, in my mission, player will create unit on trigger and that unit will board the vehicle, when player is inside. 

hint "Spawned";

_spawnpos = selectRandom ["m1","m2","m3","m4"];

_mygroup = [getmarkerpos _spawnpos, WEST, ["B_officer_F"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;

if (player in car) then {_wp = _mygroup AddWaypoint [car,0]; _wp setWaypointType "GETIN NEAREST"; _wp setWaypointStatements ["true", "{_x assignAsCargo car} foreach units _mygroup;"];};

This works, but if I'm not in vehicle prior to that, the unit will just stay there. I tried waituntil (player in car) and then _wp lines, but it will give me error...

What I'm trying to do is spawning random unit on a mark, and it will wait there until I get there in car and they will board it, we will drive somewhere and they will get out... I didn't work in changing the alpha of marker and I don't think _spawnpos setMarkerAlpha alpha will work, but I didn't try yet.

Share this post


Link to post
Share on other sites

In theory it should work but it looks like the game engine has an issue with 2 separate groups getting in at certain times.

I also never had much joy with "GETIN NEAREST" it's always been hit and miss.

 


 

hint "Spawned";

_spawnpos = selectRandom ["m1","m2","m3","m4"];

_mygroup = [getmarkerpos _spawnpos, WEST, ["B_officer_F"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;

waitUntil {player in car};

_wp = _mygroup AddWaypoint [car,0];
_wp  waypointAttachVehicle car;
_wp setWaypointType "GETIN";
_wp setWaypointStatements ["true", "{_x assignAsCargo car} foreach units _mygroup;"];

Attaching the waypoint to the vehicle and using the getin wp seems to overcome most issues and it's {} brackets in waituntil.

 

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  

×