Jump to content
Vyllis Fuhajins

Spawning a group then making it board a truck (resolved).

Recommended Posts

Hello i am newbie to scripting and arma3 editing and i can't find an answer to this:

I spawn a group of AI infantry and a truck (will be 2 IFVs when i get it to work) then set the waypoint so the AI infantry group board the truck.

 

I had no success yet. The AI infantry group move then stand still near the truck and do nothing. I would be glad if anyone can tell me what i am doing wrong.

 

This is the code for the truck:

 

 

VhcGroup = [getmarkerPos "SPA1", resistance,   ["I_Truck_02_covered_F"],[],[],[],[],[],0] call BIS_fnc_spawnGroup;

wp2 = VhcGroup addWaypoint [getMarkerPos "Load", 0];

wp2 setWaypointType "LOAD";
 

 

And this is the code for the infantry group:

 

 

RenfGroup = [getmarkerPos "SPA", resistance,   ["I_Soldier_SL_F","I_Soldier_M_F","I_Soldier_M_F","I_medic_F"],[],[],[],[],[],90] call BIS_fnc_spawnGroup;

wp1 = RenfGroup addWaypoint [getMarkerPos "Load", 10];

wp1 synchronizeWaypoint [wp2];

wp1 setWaypointType "GETIN";

 

Share this post


Link to post
Share on other sites

This video shows exactly what you want to do-handy little tutorial,if a bit out dated.

 

 

Share this post


Link to post
Share on other sites

Well, when i place the units in the editor, it does work very well. But i want to do this for units i spawn with a script so my mission wont overload the host computer.

And my spawned units with script does not board the truck :'(

Share this post


Link to post
Share on other sites

{_x moveincargo truck} foreach units RenfGroup;

Not pretty, gets the job done.

  • Thanks 1

Share this post


Link to post
Share on other sites
On 2/8/2016 at 2:30 PM, Vyllis Fuhajins said:

Thank you MKD3.

Used moveincargo and fnc_spawnvehicle. Now my infantry spawn into the freshly spawned truck.

 

Hi there. And what does this look like in the script? Can anyone describe the final solution?

Thanks in advance!

Share this post


Link to post
Share on other sites
5 hours ago, simicsko said:

 

Hi there. And what does this look like in the script? Can anyone describe the final solution?

Thanks in advance!

It depends, if you are using an editor-placed vehicle + soldiers, or created from script. Here is the wiki page for moveInCargo. So from that page you can see that the structure of the command is unit moveInCargo vehicle so if you put down a vehicle in the editor and give it a variable name then put down a unit and put this in it's init:

this moveInCargo myVehicle //replace myVehicle with the variable name you gave the vehicle

or if you created the objects from a script using createVehicle:

_soldier = createVehicle [etc...];
_vehicle = createVehicle [etc...];
_soldier moveInCargo _vehicle;

Look at moveInCargo#See_Also and you will also see other commands like moveInDriver, moveInCommander, etc

 

By the way, this command will move the unit into the vehicle instantly. If you want the unit to run up to the vehicle and "get in" like if you used the get in option in the action menu there is a different process.

See AI Group Vehicle Management for an overview.

 

The vehicle must be added to the "group" before AI can ever interact with it. Then the unit must be given (assigned) a role in the vehicle. After that, order the unit to get in the vehicle. Look at assignAsCargo#See_Also for commands to assign other roles to the AI. You may also have to allow units to get in before they are able to. I think this is default to true for new groups, but if you disallow it then you must re-allow before they are able to get in again.

 

To get the units to exit the vehicle, there is doGetOut, but I've found that this is pretty slow as the units will exit the vehicle one by one. A much better command in my opinion is moveOut. You will also need to orderGetIn with false, otherwise they will just get back in the vehicle

 

That should get you started in the right direction

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

×