From 8e3b2934f374dee0c98aad766342a8cde2362ca6 Mon Sep 17 00:00:00 2001 From: "Marek S. Lukasiewicz" Date: Wed, 17 Dec 2025 15:35:52 +0100 Subject: [PATCH] Display numeric values on PFD --- project/instruments/pfd.gd | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/project/instruments/pfd.gd b/project/instruments/pfd.gd index bd92309..43790a0 100644 --- a/project/instruments/pfd.gd +++ b/project/instruments/pfd.gd @@ -25,10 +25,6 @@ extends Node2D set(value): altitude = value var step = 1 - if value > 49.5: - step = 5 - if value > 99.5: - step = 10 altitude_label.text = str(int(step * round(value / step))) @export var climbrate: float = 1000: @@ -48,3 +44,15 @@ extends Node2D func update(aircraft: Transform3D, velocity: Vector3): var godot_euler = aircraft.basis.get_euler() euler_attitude_deg = Vector3(godot_euler.z, -godot_euler.x, -godot_euler.y) * rad_to_deg(1) + + const mps_to_kt = 1.94384 + var v_local = aircraft.basis.inverse() * velocity + airspeed = max(0, v_local.z) * mps_to_kt + var v_horizontal = Vector3(velocity.x, 0, velocity.z) + groundspeed = v_horizontal.length() * mps_to_kt + + const mps_to_fpm = 196.848 + climbrate = velocity.y * mps_to_fpm + + const m_to_ft = 3.2808 + altitude = aircraft.origin.y * m_to_ft