NWH Aerodynamics
Search Results for

    Show / Hide Table of Contents

    HUD_Attitude

    HUD_Attitude inspector.

    Purpose and Role

    The HUD_Attitude instrument displays aircraft pitch and roll attitude on a moving artificial horizon display. It reads the Pitch and Roll properties from the aircraft controller and translates them into visual pitch/roll representation through a rotating horizon line or pitch ladder. This creates the classic "artificial horizon" or "attitude indicator" found in aircraft cockpits.

    Data Source and Update Mechanism

    The instrument continuously reads:

    • Pitch from AircraftController.Pitch (degrees, -90 to +90)
    • Roll from AircraftController.Roll (degrees, -180 to +180)
    • Updates every frame in LateUpdate()

    Configuration Properties

    Visual Components

    • Artificial Sky (Transform) - Rotating outer ring showing artificial sky/earth

      • Rotates with roll angle
      • Usually contains blue (sky) and brown (earth) coloring
      • Rotates around Z-axis based on aircraft roll
    • Horizon (Transform) - Background element without markings

      • Stationary or provides reference background
      • Defines the primary visual element for horizon detection
    • Pitch Indicator (Transform) - Pitch/roll ladder with horizon line

      • Moves vertically with pitch angle
      • Can move horizontally for slip/turn correction
      • Usually shows pitch markings (0°, 5°, 10°, etc.)

    Scaling Parameters

    • Units Per Degree (float) - Movement units per degree of pitch/roll change
      • Default: 1.4 (pixels for UI, or meters for 3D)
      • 1 pixel per degree typical for UI
      • 0.001 units per degree typical for 3D
      • Controls sensitivity of pitch/roll display

    Pitch and Roll Representation

    Roll Display

    The artificial sky rotates with aircraft roll angle:

    • Roll = 0°: Horizon is level
    • Roll = 90°: Horizon is vertical (wings perpendicular)
    • Roll = -90°: Horizon is inverted vertical
    • Rotation applied around Z-axis

    Pitch Display

    The pitch indicator moves vertically with pitch angle:

    • Pitch = 0°: Indicator centered (level flight)
    • Pitch = +30°: Indicator moves up (nose up)
    • Pitch = -30°: Indicator moves down (nose down)
    • Movement = pitch * unitsPerDegree pixels/units

    Aircraft Source Configuration

    • Manual Source (default)

      • Directly assign targetAircraftController in inspector
    • Vehicle Changer Source

      • Automatically switches to active vehicle

    Setup Instructions

    Basic Setup for 3D Cockpit

    1. Create artificial horizon sphere or background with sky/earth gradient
    2. Create pitch ladder object with markings
    3. Create horizon line/cross indicator
    4. Assign transforms to Artificial Sky, Horizon, and Pitch Indicator
    5. Set Units Per Degree (typically 1-2 pixels for UI, 0.001 for 3D)
    6. Assign target aircraft controller
    7. Test in Play mode by rolling and pitching aircraft

    Canvas (UI) Setup

    1. Create Canvas with Image for background
    2. Create Image for rotating artificial sky
    3. Create RectTransform for pitch indicator (moves vertically)
    4. Assign RectTransforms to the instrument
    5. Set Units Per Degree to pixel-per-degree sensitivity

    Public API

    Properties

    artificialSky

    Type: Transform

    Outer ring of the attitude instrument. Shows artificial sky and artificial earth. Rotates with the roll angle to maintain proper horizon orientation. Usually contains blue coloring for sky and brown/tan for earth.

    horizon

    Type: Transform

    Background element without any markings. Provides the reference background for the attitude indicator display. Rotates with roll angle to keep the horizon visually aligned.

    pitchIndicator

    Type: Transform

    The pitch/roll indicator object. Usually displays a ladder with horizon line and pitch values (0°, 5°, 10°, etc.). Moves vertically with pitch angle and horizontally for slip/turn correction. Works with both RectTransforms (UI) and regular Transforms (3D cockpit).

    unitsPerDegree

    Type: float Default: 1.4f

    Scaling factor for pitch and roll movement. Controls the sensitivity of the pitch/roll display:

    • For RectTransforms (UI): Value in pixels per degree. Typical range: 0.5-2.0 pixels per degree
    • For Transforms (3D): Value in world units per degree. Typical range: 0.0005-0.002 units per degree
    • Default value (1.4) provides reasonable sensitivity for most UI implementations

    Inherited Properties

    From HUD_Instrument:

    targetAircraftController

    Type: AircraftController

    The aircraft controller that provides pitch and roll data via the Pitch and Roll properties.

    aircraftSource

    Type: AircraftSource (enum: Manual, VehicleChanger)

    Determines how the target aircraft is assigned:

    • Manual: Manually assign via Inspector or code
    • VehicleChanger: Automatically tracks active vehicle from VehicleChanger system

    Common Usage Patterns

    Basic Flight Indication

    HUD_Attitude attitudeIndicator = GetComponent<HUD_Attitude>();
    
    // Automatically updates with aircraft orientation
    // No code needed for basic operation
    

    Custom Pitch Sensitivity

    // Adjust pitch sensitivity
    attitudeIndicator.unitsPerDegree = 2.0f;  // More exaggerated pitch movement
    

    Integration with Other Systems

    • AircraftController - Source of pitch and roll data
    • VehicleChanger - Optional automatic aircraft source switching
    • HUD_Instrument - Base class providing common instrument functionality
    • Other HUD instruments - Share same aircraft reference

    Real-World Context

    Attitude Interpretation

    • Wings level, pitch 0°: Straight and level flight
    • 10° pitch up, wings level: Gentle climb
    • 20° bank, pitch 5° up: Banked climb
    • 90° bank: Wings perpendicular (knife-edge)

    Pilot Training Context

    The attitude indicator is one of the six primary flight instruments:

    1. Airspeed Indicator (speed)
    2. Attitude Indicator (pitch and roll) ← This component
    3. Altimeter (altitude)
    4. Turn Coordinator (turn rate)
    5. Heading Indicator (direction)
    6. Vertical Speed Indicator (climb rate)

    Troubleshooting

    Horizon Not Level in Level Flight

    • Verify aircraft pitch/roll return to 0° when level
    • Check AircraftController physics configuration
    • Verify pitch indicator is centered when aircraft is level

    Movement Too Sensitive or Not Sensitive Enough

    • Adjust Units Per Degree value
    • For UI: Typical 0.5-2.0 pixels per degree
    • For 3D: Typical 0.0005-0.002 units per degree

    Roll Indicator Rotating Wrong Direction

    • Reverse the sign of rotation or adjust transform alignment

    Related Classes

    • HUD_Instrument - Base class for all flight instruments
    • AircraftController - Source of pitch and roll data
    • HUD_Airspeed - Airspeed display instrument
    • HUD_Altimeter - Altitude display instrument
    • HUD_Heading - Compass heading indicator
    • HUD_Turn - Turn rate indicator
    • HUD_VerticalSpeed - Vertical speed indicator
    • Edit this page
    In this article
    Back to top Copyright © NWH - Vehicle Physics, Aerodynamics, Dynamic Water Physics