HOW TO CREATE AIRCRAFT MOVEMENT IN UNITY

Build high-speed arcade jet dogfighting physics featuring forward throttle, responsive aileron rolls, elevator pitch, and wing lift aerodynamics.

Quick Answer

In Unity, aircraft movement uses a Rigidbody where forward thrust is pushed along transform.forward, aerodynamic wing lift is calculated via Vector3.Dot(rb.linearVelocity, transform.forward) * transform.up, and pitch/roll/yaw angular rotations are applied through rb.MoveRotation().

1

Arcade Fighter Jet Controller C# Script

JetFlightController.cs (C#)
using UnityEngine;

[RequireComponent(typeof(Rigidbody))]
public class JetFlightController : MonoBehaviour
{
    [Header("Engine Thrust")]
    [SerializeField] private float baseThrust = 40f;
    [SerializeField] private float boostMultiplier = 1.8f;
    [SerializeField] private float maxSpeedKmh = 950f;

    [Header("Maneuverability Speeds")]
    [SerializeField] private float pitchSpeed = 50f;  // Nose Up/Down
    [SerializeField] private float rollSpeed = 90f;   // Aileron Banking
    [SerializeField] private float yawSpeed = 25f;    // Rudder Steering

    [Header("Aerodynamic Wing Lift")]
    [SerializeField] private float liftCoefficient = 0.8f;

    private Rigidbody rb;
    private float pitchInput;
    private float rollInput;
    private float yawInput;
    private bool isBoosting;

    public float CurrentSpeedKmh => rb.linearVelocity.magnitude * 3.6f;

    private void Awake()
    {
        rb = GetComponent<Rigidbody>();
        rb.useGravity = true;
        rb.linearDamping = 0.15f;
        rb.angularDamping = 2.0f;
    }

    private void Update()
    {
        // Pitch: W (Nose down) / S (Nose up)
        pitchInput = Input.GetAxis("Vertical");
        // Roll: A / D (Banking)
        rollInput = -Input.GetAxis("Horizontal");
        // Yaw: Q / E (Rudder)
        yawInput = 0f;
        if (Input.GetKey(KeyCode.Q)) yawInput -= 1f;
        if (Input.GetKey(KeyCode.E)) yawInput += 1f;

        // Boost / Afterburner: Left Shift
        isBoosting = Input.GetKey(KeyCode.LeftShift);
    }

    private void FixedUpdate()
    {
        ApplyThrust();
        ApplyLift();
        ApplyFlightRotations();
    }

    private void ApplyThrust()
    {
        float currentThrust = baseThrust * (isBoosting ? boostMultiplier : 1f);
        
        if (CurrentSpeedKmh < maxSpeedKmh)
        {
            rb.AddForce(transform.forward * currentThrust, ForceMode.Acceleration);
        }
    }

    private void ApplyLift()
    {
        // Wing lift is generated when forward airflow hits wings
        float forwardVelocity = Vector3.Dot(rb.linearVelocity, transform.forward);
        if (forwardVelocity > 0)
        {
            Vector3 lift = transform.up * (forwardVelocity * liftCoefficient);
            rb.AddForce(lift, ForceMode.Acceleration);
        }
    }

    private void ApplyFlightRotations()
    {
        Vector3 rotationDelta = new Vector3(
            pitchInput * pitchSpeed,
            yawInput * yawSpeed,
            rollInput * rollSpeed
        ) * Time.fixedDeltaTime;

        Quaternion deltaQuat = Quaternion.Euler(rotationDelta);
        rb.MoveRotation(rb.rotation * deltaQuat);
    }
}

Equip Combat Weaponry