Jump to content
Sign in to follow this  
blackettle

Using moveinCargo while vehicle is in the air

Recommended Posts

I am attempting to fill a C130 that is already in the air with units. However, they are not being moved into the cargo of the c130 as expected and I wonder if it has anything to do with the vehicle being in the air.

Share this post


Link to post
Share on other sites

Nope, that won't matter. The C-130 isn't full is it? How are you typing the moveInCargo line?

Share this post


Link to post
Share on other sites

The c130 is not full and the following shows 24 free positions:

_freePositions = _x emptyPositions "Cargo";

i am trying to move new units into the c130 with something like:

_unit = "USMC_Soldier" createUnit [_pos, _grp];

_unit moveInCargo _x;

where _x is the c130 object.

Share this post


Link to post
Share on other sites

Where are you declaring that _x is the c130?

Also _x is reserved for "current item" in things like loops and foreach blocks, so you should change that to something like _plane or some other custom variable so you won't run into problems later from using a reserved keyword.

Also createUnit doesn't return anything (technically returns Nothing) so _unit = "bleh" createUnit won't work as you're expecting it to.

Use something like this instead:

"US_Soldier_B_EP1" createUnit [position player, group player, "unit = this"];  unit moveInCargo c1;

Edited by kylania

Share this post


Link to post
Share on other sites

Actually the above code is enclosed in a foreach loop.

in your code, what is the :

... ,"unit = this"];

part doing?

Share this post


Link to post
Share on other sites
Actually the above code is enclosed in a foreach loop.

in your code, what is the :

... ,"unit = this"];

part doing?

That's the init field for the newly created unit allowing you to use "unit" as it's name for when you move it into the C-130. The other option would be to use createVehicle instead which does allow you to do something like _unit = "bleh" createVehicle... and refer to _unit as the unnamed object.

Share this post


Link to post
Share on other sites

I finally got around to trying this code and it seems to work.

It does seem a bit counter intuitive to do it like that. Is there no other way? It seems a bit inconsistent that createVehicle returns a vehicle object while createUnit returns nothing at all.

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  

×