Spawning into a Flying Aircraft
Most vehicles are easy enough to get into a running Arma 3 mission with a createVehicle call, but when you need an aircraft it isn't quite so simple. Rather than trying to spawn an aircraft on a runway and in the correct direction—and then spending time to get it in the air—this script creates an aircraft that is already flying and moves a unit straight into it.
The first thing to try with this snippet is to stick yourself into a flying A-164 Wipeout:
[] call fhcb_spawnFlyingAircraft;
For a specific aircraft, specify the class name:
["O_Plane_CAS_02_F"] call fhcb_spawnFlyingAircraft;
The initial altitude, position and direction can also be specified. This usage example moves the player into a flying aircraft, heading east, 1000 meters above the "planeSpawnPoint" marker position:
[ "O_Plane_CAS_02_F", player, 1000, getMarkerPos "planeSpawnPoint", 90 ] call fhcb_spawnFlyingAircraft;
The snippet that must be executed first—to define the fhcb_spawnFlyingAircraft function so that the above examples will work—is:
fhcb_spawnFlyingAircraft = { params [ ["_planeClass", "B_Plane_CAS_01_F"], ["_pilot", player]]; params [ "", "", ["_altitude", 200], ["_groundPosition", getPos _pilot], ["_direction", getDir _pilot]]; private _position = _groundPosition vectorAdd [0, 0, _altitude]; private _speedProportion = 0.5; private _landingSpeed = getNumber (configFile >> "CfgVehicles" >> _planeClass >> "landingSpeed"); private _maxSpeed = getNumber (configFile >> "CfgVehicles" >> _planeClass >> "maxSpeed"); private _speed = _speedProportion * (2 * _landingSpeed + _maxSpeed); if (!local _pilot) exitWith { }; private _plane = createVehicle [_planeClass, _position, [], 200, "FLY"]; _plane setDir _direction; _plane setPos _position; _plane setVelocity ([sin _direction, cos _direction, 0] vectorMultiply (_speed / 3.6)); _pilot assignAsDriver _plane; _pilot moveInDriver _plane; _plane };
One thing to note about this snippet is that it doesn't let you specify the initial speed. Instead, it calculates a reasonable speed by taking a value somewhere between the landing and maximum speeds that are defined for each aircraft in Arma 3's configuration files.