Gravity keeps us grounded, for me, flight physics did it for me. Just when I thought I understood planes a little bit I am brought back down. So let me walk you through
How to make a plane fly
Which is a lie, I am not going to show how to, just what I did. First of all, planes are a lot more complicated than you might think, the more you look into it, the more you realize you know nothing of it—though that applies to a lot of subjects, programming included. The first time I approached this subject was in a quite unorganized manner. I had some knowledge and I was naive enough to think it would be sufficient, and while I was able to make the plane fly it wasn't as good as I would have wanted. Instead of using a rigidbody I ended up using a character controller, which added more work for me as I needed to apply the forces myself. A lot of technical debt piled on me and so I gave up on the project and decided to start anew. This time, I was going to spec it thoroughly, a small mistake here and there, but anything physics related, it was written and documented in the specification. This entailed a lot of
Research
I used to not do enough research, but I learned the hard way, I would rather spend more time researching a topic than blindly accept one answer. So I looked up things about planes. Let's start with something I am familiar with. All planes need some kind of
Thrust
Turboprop, Turbofan, Turbojet, I can name more, thrust is essential to aircraft, it's The thing that makes the plane move, it pushes or pulls(depending on thruster type) the plane. For example in a turboprop, there is an engine that spins the propeller fast enough to pull air to the back, push is just making air go back fast enough like you are trying to move a heavy drawer from the wall and you are pushing with your back...kind, in a vague way. Mind you there are configurations that do the opposite, for example a prop in the back that pushes the plane.

This is by far the simplest thing you can add in your flight physics model, it's just adding force gradually to an object, all it does is make a hunk of metal slide forward.
Vector3 force = transform.forward * enginePower * throttle; rb.AddForce(force, ForceMode.Force);
It's not enough to make the plane fly, you also need
Lift
Which is something I could explain, if I had the brains for it. In short, it's like when you put your hand out the window of a moving car, keep flat and angle it up a bit and you will feel the wind try to lift your hand up, and if you cup your hands, the effect is more noticeable.
In essence that's the force you apply to make the plane glide and stay in the air. Combined with thrust.
Vector3 force = transform.up * liftMagnitude; rb.AddForce(force, ForceMode.Force);
Now you can cruise, but what about take off? Ah now you need to adjust your
Angle of Attack
This is tied to how lift is generated, take our example from before, angled hand generates lift, tilt up will create more lift, and tilt down, now you are creating downforce. This is pretty common in motorsports, usually as a spoiler or in Formula as wings. When downforce is applied the pressure tries to keep the car as planted as possible, so drivers can take corners faster. In aircrafts, these are called airfoils, and they come in different shapes. When you cup your hand, you feel more lift, that's the common teardrop shape doing its job, just a slight variation but different result. Of course in our code we don't take into account the shape, we just use numbers to do it
angleOfAttack = Mathf.Atan2(-localVelocity.y, localVelocity.z) * Mathf.Rad2Deg; liftCoefficient = profile.liftCoefficientCurve.Evaluate(angleOfAttack);
One moment though, what happens if we get greedy? Say we tilt up too much, well you simply
Stall
A state in which the plane has no lift because the air just can't flow smoothly over the top of the wing, quite a scary scenario in real life. Before you get into a deep stall which are harder to recover from, you pitch the nose down sacrificing altitude to regain speed and let the air flow smoothly over the wings again.
// Past critical AoA, the nose naturally drops — pushes toward lower AoA float noseDownTorque = stallDepth * stallNoseDownTorque; rb.AddRelativeTorque(Vector3.right * -noseDownTorque, ForceMode.Acceleration);
Great, we recovered from the stall and are now cruising, the problem is, we have to get around a mountain, we need
Rotational Movements
Unlike cars, aircrafts have attitude, no really that's the name. It encompasses many things at once. First we have
Pitch
Orientation of the nose, either up and down. You'd say "oh so it controls the Angle of Attack?" And you'd be half right....maybe quarter right. This only controls the nose's orientation relative to the horizon.
rb.AddRelativeTorque(Vector3.right * pitchInput * pitchAuthority, ForceMode.Acceleration);
Oh shoot, forgot we have a mountain in front of us, pitch is not helping us here we need to
Roll
Tilts the plane sideways so that the wings are up and down. This alone isn't sufficient, we need to add pitch while we roll to start
rb.AddRelativeTorque(Vector3.forward * -rollInput * rollAuthority, ForceMode.Acceleration);
Banking
The most common and really the best/most effective way to turn an aircraft to a different flight path. In this state we use the pitch to generate lift. Now the pitch no longer controls the nose's orientation relative to the horizon, it's helping us turn. In our situation, aligned vertically relative to horizon, the bank will be quite harsh, and the nose isn't perfectly following the turn. Now we need to
Yaw
The thing most people think turns the plane. It is in fact used in mainly two scenarios, to control the aircraft's direction while taxiing on the ground, or to make adjustments by nudging the nose a certain direction.
rb.AddRelativeTorque(Vector3.up * yawInput * yawAuthority, ForceMode.Acceleration);
That's pretty much it for yaw, really, nothing crazy. It's not the most impressive thing in a plane, though there comes scenarios when the poor rudders become champs and act like elevators controlling pitch. Let me not confuse you any further and let's move on. See, we took off, gained altitude and dealt with the aircraft's attitude.
And that is how you make a plane fly. I said nothing about it being realistic. To truly make it realistic, here is a list of what's missing.
- Drag (parasitic, induced, wave)
- Weight and center of gravity
- Torque effect
- P-factor
- Adverse yaw
- Gyroscopic precession
- Ground effect
- Wind (headwind, crosswind, tailwind)
- Turbulence
- Air density changes with altitude
- Engine torque roll
- Slip and skid
- Trim
- Flap and slat effects
- Wake turbulence
- Compressibility at high speed
Second entry. The plane now flies.