Porting A Fortran Flight Simulator To Unity3D

There’s an old saying (paraphrasing a quote attributed to Hoare): “I don’t know what language scientists will use in the future, but I know it will be called Fortran.” The truth is, there is a ton of very sophisticated code in Fortran, and if you want to do something more modern, it is often easier to borrow it than to reinvent the wheel. When [Valgriz] picked up a textbook on aircraft simulation, he noted that it had an F-16 simulation in it. In Fortran. The challenge? Port it to Unity3D.

If you have a gamepad, you can try the result. However, the real payoff is the blog posts describing what he did. They go back to 2021, although the most recent was a few months ago, and they cover the entire process in great detail. You can also find the code on GitHub. If you are interested in flight simulation, flying, Fortran, or Unity3D, you’ll want to settle in and read all four posts. That will take some time.

One limitation. The book’s simulator was all about modeling the aerodynamics using data from wind tunnel tests. However, the F-16 is notorious for being a negative stability aircraft — meaning it’s virtually impossible to fly by hand. It is very maneuverable, but only if you let the computer drive using the flight control system. When you direct the aircraft, the control system makes your desire happen, while accounting for all the strange extra motions the plane will create as it flies.

The problem: the book doesn’t include code for the flight controller. [Valgriz], of course, wrote his own. He uses some PID controllers along with limiters for G-force and angle of attack. Interestingly, to do this, the simulator actually runs its own stripped-down simulator to determine the effects of different control inputs.

This is one of those projects we aren’t sure we would attempt, but we’re glad someone did, and we can watch. Just be careful. An interest in flight simulation can lead to reduced space in your garage. We know of at least one F-16, by the way, that has an Arduino in it. However, it is probably the only one.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.