Jump to content
Sign in to follow this  
NGagedFX

Spawning an airplane

Recommended Posts

I want to spawn a C-130 and have it follow a pre-recorded path. This works perfectly fine, except for the engines that will be turned off when spawning, and I have no idea how to get them on. The ["EngineOn",this] didn't do it and spawning an AI to performing the EngineOn command on him didn't work either (I can't get him to get teleport into the driver position).

script.sqf

supplyPlane = "C130J_US_EP1" createVehicle [13091.7,844.617,803.322];
pilot createUnit [position player, this, "US_Soldier_Pilot_EP1",1,"Corporal"];
pilot moveInDriver supplyPlane;
pilot action ["ENGINEON",this];
supplyPlane action ["ENGINEON",this];
result = [] call MyPath;
supplyPlane exec "supplyPlaneFDP.sqf";
supplyPlane exec "supplyDrop\drop_StrikerMGS.sqs";
My_group1 setVariable ["groupCredits", ((My_group1 getVariable "groupCredits") - 2), true];
nil = [My_group1] execVM "scripts\credits.sqf";
sleep 90;
deleteVehicle supplyPlane;

Does anyone know what I'm doing wrong? :confused:

Edited by NGagedFX
Added [co de] [/co de] tags

Share this post


Link to post
Share on other sites

When you spawn an empty aircraft it's velocity is 0. My guess that is you need to give the plane a little push after you put the pilot in the seat and turn on the engines.

Share this post


Link to post
Share on other sites

I think the main reason it doesn't work is that the createUnit seems to be incorrect. Try this:

"US_Soldier_Pilot_EP1" createUnit [getMarkerPos "spawnPlane", group player, "this moveInDriver supplyPlane",1,"Captain"];

"this" will not work where I have "group player" and you have to pass the unit type at the front inside a string. It doesn't need to be group player of course. I do this in my scripts:

_group = createGroup _side;

where _side is west, east, resistance, civilian, or whatever else is allowed (no quotes).

Also Grimes is correct in the sense that some fixed wing aircraft do need a push. I've seen spawned jets go backwards and flip over and crash. The C130 seems to be handling itself ok in my testing. Here is the code I used in full just now:

_heading = 330;
_speed = 150;
_velx = (sin _heading * _speed);
_vely = (cos _heading * _speed);
_velz = 0;

_posx = getMarkerPos "spawnPlane" select 0;
_posy = getMarkerPos "spawnPlane" select 1;
_posz = 100;
_newVeh = createVehicle ["C130J_US_EP1", [_posx, _posy, _posz], [], 0, "FLY"];
_newVeh setDir _heading;
_newVeh setVelocity [_velx, _vely, _velz];

"US_Soldier_Pilot_EP1" createUnit [getMarkerPos "spawnPlane", group player, "this moveInDriver _newVeh",1,"Captain"];

The _velx/y/z is to get the correct direction for the push, multiplied by start speed which I have set to 150. After it's spawned, I set it's velocity.

Share this post


Link to post
Share on other sites

How do you name the group you create with FuncSpawnGroup? I want to dynamically create/delete groups and in orderto do that I need to have it named so I can execVM my deletesquad.sqf with a proper group name once the trigger is "deactivated" by the player leaving the area

Share this post


Link to post
Share on other sites

There was another thread about this and I did this little demo......might help you with the respawning.

Grimes and AzCoder are right in saying you need to give them a push...otherwise they just tumble out of the sky!

Share this post


Link to post
Share on other sites

Thanks for all the replies. But a little note about the ''push'': in the flight path data that is saved when recording, there is already the position, vector and velocity data right? So why would you still need to give it a push?

Anyway, I solved it by creating a pilot in No Man's Land and teleporting him into the driver position which strangely solved the whole problem I've been toasting my brains on for over a few hours.

There is only 1 thing left: How do you make this pilot guy lower the gears of a C-130? I tried pilot action ["LandGear", nameofplane]; which didn't work and later on put doStop pilot; in front of it which still didn't work. :confused:

Share this post


Link to post
Share on other sites

If you read the first part of my answer, I showed how to correct the spawn unit which is all I had to do for it to fly. The push is for high performance aircraft. The C130 doesn't need, helos don't need it, but jets do ;)

Also not sure what you mean about prerecorded path? You mean waypoints? When a vehicle is spawned, it has no velocity, but will try to meet requirements of first waypoint, if it doesn't crash first...

Oh, no idea on the last one, maybe it needs a SAFE waypoint and low enough velocity?

Edited by AZCoder

Share this post


Link to post
Share on other sites

I think I didn't make quite clear that I recorded myself :p For those who don't know yet: OA support 2 new commands, UnitCapture and UnitPlayback. With these it is possible to record your movement and fire data when flying aircrafts.

So your first part didn't work for me. :( Even stranger: even though the object gets it's position updated 30 time a second, it didn't follow this path unless there was someone somewhere in the plane. :confused:

Share this post


Link to post
Share on other sites

Ah, I haven't tried that new recording process yet, hope to find time soon. But it does work now with the moveInDriver method? I've done it that way lots of times. I noted that in BIS missions they sometimes put allowdamage false in the unit's init line, just in case something tries to kill him before he's needed. You can also render him invisible, at least to the player.

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  

×