Jump to content
Sign in to follow this  
spamurai

createVehicle questions

Recommended Posts

I have discovered the createVehicle command. However, I have some question about whats going on.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">unitName = createVehicle ["Type", "Position", "Marker", "Placement Radius", "Special"];

After experimenting a bit, I've figured out what's mostly going on inside the command, but...

inside the arrary is the "Position" detailed in [x,y,z] form... however, no matter what I set the height too (z), the new vehicle is always on the ground at 0m. Is "z" redundent? If I fail to include Z element in the array, a script error complains of the array expecting 3 elements, but found only 2.

If I set the "Special" to FLY for a helicopter (for example), it starts in the air, with engine running, but not at the specified height.

The second mystery, is "Marker"... I could not figure out what significance this has... it has to be a string, but if I enter in a Marker name... no errors are reported, but the vehicle does not appear...? If I leave it at [] the vehicle appears in it's "Position" and adjusted by it's "Placement Radius".

Share this post


Link to post
Share on other sites
Quote[/b] ]I have discovered the createVehicle command.

Congrats! Great command, isnt it?  biggrin_o.gif

Quote[/b] ]however, no matter what I set the height too (z), the new vehicle is always on the ground at 0m.

simply run a setPos command after creating the object:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_myunit = createVehicle ["M1Abrams", getPos player, [], 0, "NONE"];

_myunit setPos ((getPos _myunit) set [2, 100]);     // second value in the array is the height

Quote[/b] ]If I set the "Special" to FLY for a helicopter (for example), it starts in the air, with engine running, but not at the specified height.

run a flyInHeight after creating the chopper

Btw, check this link: The OFPEC COMREF

Share this post


Link to post
Share on other sites

The, <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _myunit setPos ((getPos _myunit) set [2, 300]); doesn't work. However, <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_myUnit setPos [_spawnX, _spawnY, 300];

works great Thanks smile_o.gif

I still do not know the significance of the "Marker" element in the array though :/

Also... I seem to be having trouble spawning crew into the newly created vehicle... I spawn crew... but not in the vehicle.

Share this post


Link to post
Share on other sites
Quote[/b] ]Also... I seem to be having trouble spawning crew into the newly created vehicle... I spawn crew... but not in the vehicle.

That's what the moveInDriver, moveInGunner, moveInCommander, moveInCargo and moveInTurret commands are for. Once again run them after creating the crew unit.

Share this post


Link to post
Share on other sites
Quote[/b] ]Also... I seem to be having trouble spawning crew into the newly created vehicle... I spawn crew... but not in the vehicle.

That's what the moveInDriver, moveInGunner, moveInCommander, moveInCargo and moveInTurret commands are for. Once again run them after creating the crew unit.

I'm trying too, and the pilot spawns in... but he's outside the helicopter...

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_pilot = objNull;

_helo = objNull;

_target = getMarkerPos "helotarget";

_spawnpoint = getMarkerPos "helospawn";

_spawnX = getMarkerPos "helospawn" select 0;

_spawnY = getMarkerPos "helospawn" select 1;

_westGroup = createGroup West;

_helo = createVehicle ["UH60MG",_spawnpoint,[], 0, "FLY"];

_helo setPos [_spawnX, _spawnY, 150];

_pilot = "SoldierWPilot" createUnit [_spawnpoint, _westGroup];

_pilot assignAsDriver _helo;

_pilot moveInDriver _helo;

Share this post


Link to post
Share on other sites

I did it! YAHOO!

biggrin_o.gif

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_target = getMarkerPos "helotarget";

_spawnpoint = getMarkerPos "helospawn";

_spawnX = getMarkerPos "helospawn" select 0;

_spawnY = getMarkerPos "helospawn" select 1;

_westGroup = createGroup West;

_helo = createVehicle ["UH60MG",_spawnpoint,[], 0, "FLY"];

_helo setPos [_spawnX, _spawnY, 150];

_pilot = _westGroup createUnit ["SoldierWPilot",_spawnpoint,[], 0, "NONE"];

_pilot moveInDriver _helo;

_pilot assignAsdriver _helo;

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  

×