Translating a Fortran F-16 Simulator to Unity3D This article chronicles the process of porting a classic F-16 flight simulator, originally written in Fortran from the textbook Aircraft Control and Simulation by Stevens, Lewis, and Johnson, into C# using the Unity3D engine. It serves as a deep dive into realistic flight modeling, aerodynamics, engine simulation, and flight control systems (FCS). The project is a major step beyond basic game-style flight sims and moves toward professional-level simulation fidelity. --- Overview and Motivation The original F-16 flight model is based on wind tunnel data with lookup tables and equations, but all in Fortran. The author aims to translate this to Unity3D to provide a more realistic flight simulator than a previous hand-tuned simplified model. The model captures intermediate-level parameters rather than low-level CFD or purely game-tuned high-level controls. Source code is available on GitHub, and a playable demo is on itch.io. --- Aerospace Conventions Coordinate System: Aerospace uses right-handed coordinates with X forward, Y right, Z down, differing from Unity’s left-handed Y-up system. Conversions: Simple vector and angle conversions are defined between Unity and aerospace systems. Units: US customary units prevail in aerospace texts: Distance: feet Mass: slugs (1 slug ≈ 14.59 kg) Speed: feet per second and knots (nautical miles/hr) Temperature: degrees Rankine (like Kelvin but Fahrenheit-based) Unit conversions to/from metric are essential for Unity integration. --- Air Data Computations Real aircraft measure static and dynamic pressures to calculate parameters such as indicated airspeed. The simulation reverses this: starting with velocity and altitude, it calculates dynamic pressure (QBAR) and Mach number. The Fortran subroutine ADC is translated into C# with corresponding physical constants and unit conversions, handling temperatures and air density variations with altitude. --- Lookup Tables and Interpolation Aerodynamics data uses 1D, 2D, and 3D lookup tables for coefficients and thrust. 1D linear interpolation handles values often outside the table range via extrapolation. 2D bilinear interpolation extends this concept, interpolating values inside a 2D grid. Engine thrust is calculated via trilinear interpolation (by interpolating between three 2D tables for idle, military, and max power). --- Engine Modeling Jet engine thrust depends on throttle, altitude, and speed, more realistic than a linear multiplier. Throttle input is translated via a piecewise linear function ("throttle gearing") to power. Engine power changes gradually over seconds, simulating RPM lag and preventing compressor stalls. Afterburner engages above 77% throttle (~50% power), increasing thrust quickly without raising RPM further. Thrust is interpolated through multiple tables using mach and altitude data. The engine model smoothly transitions between idle, military, and maximum thrust states. --- Aerodynamic Forces and Moments The flight model calculates normal force (perpendicular to nose) rather than lift force (perpendicular to velocity), drag, and side force coefficients via lookup tables and control surfaces inputs. Moment (torque) around pitch, roll, and yaw axes is computed using aerodynamic moment coefficients and moment of inertia parameters. Damping coefficients reduce angular velocities, mimicking aerodynamic angular drag. Control surfaces influence moments: elevator predominantly affects pitch, ailerons and rudders affect roll and yaw moments. --- Complete Flight Model Implementation Uses state vector including velocity, angles, angular velocities, altitude, engine power. Translates forces and moments to acceleration and angular acceleration considering the moment of inertia