Page MenuHomeFeedback Tracker

USS Freedom catapult acceleration [DEV Branch]
New, NormalPublic

Description

During the catapult launch on the USS Freedom, all aircraft are accelerated to launch velocity almost instantly. This is not very realistic and looks a bit jarring during gameplay.

Behavior is created in BIS_fnc_AircraftCatapultLaunch. This report also includes a rewritten version of this function to demonstrate a smooth launch with minimized constant acceleration.

Details

Severity
Tweak
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
General
Steps To Reproduce
  1. Attach any aircraft to the catapult.
  2. Complete the hold button action.
  3. Get accelerated to ~300 km/h in an instant.
Additional Information

Evaluating BIS_fnc_AircraftCatapultLaunch allows me to conclude that this code is flawed.

A set amount of velocity "_launchVelocityIncrease = 10 m/s" is added every iteration of a while loop until the plane reaches "_launchVelocity = 300 km/h".

The acceleration is finished in (300/3.6)/10~8 steps, so with an iteration sleep "_launchAccelerationStep = 0.001 s" we get a launch duration of ~0.008 seconds and therefore an acceleration of (10/0.001)/9.81 ~1000 G. This will probably turn a pilot into meat sauce.

The iteration sleep of 0.001 seconds is WAY too short as it runs the code ~10-40 times per frame.
The velocity increase on each step must depend on that sleep.

We can determine the minimum acceleration needed to get the plane to launch velocity within the length of the catapult with some basic physics:

L_cat = 0.5*at^2,    v_end = at    -> dv/dt = a = 0.5*v_end^2/L_cat    -> dv = a*dt

A rewritten BIS_fnc_AircraftCatapultLaunch:

private _plane = param [0,objNull]; if (!local _plane) exitWith {};

private _configPath = configFile >> "CfgVehicles" >> typeOf _plane;
private _launchVelocity = ((_configPath >> "CarrierOpsCompatability" >> "LaunchVelocity") call BIS_fnc_getCfgData)/3.6; // km/h to m/s
if(isNil "_launchVelocity") then {_launchVelocity = 210/3.6;}; // km/h to m/s
private _launchAccelerationStep = 0.05; // Change in configs
private _launchLength = 120 - 20; // Length of catapult minus a safety length to accelerate faster to prevent blowing up on the deck
private _launchVelocityIncrease = (0.5*_launchVelocity^2/_launchLength)*_launchAccelerationStep; // ~3 G
_plane engineOn true;
private _planeDir = vectorDir _plane; // setVectorDir gives smoother results than setDir at any FPS
private _velInitial = velocityModelSpace _plane;

// Catapult launches whether engine is on or off once it starts moving: no turning back!
while {vectorMagnitude _velInitial < _launchVelocity} do {
	_velInitial = velocityModelSpace _plane;
	_plane setVectorDir _planeDir;
	_plane setVelocityModelSpace (_velInitial vectorAdd [0,_launchVelocityIncrease,0]);
	sleep _launchAccelerationStep;
};

Event Timeline

John5 added a subscriber: John5.May 2 2017, 10:49 PM
Aebian added a subscriber: Aebian.May 3 2017, 8:35 AM