From 46a030f15ef4305ef70bd9eb08db5c4e09d72a37 Mon Sep 17 00:00:00 2001 From: yuni Date: Tue, 11 Jun 2024 01:12:41 +0200 Subject: [PATCH] speedometer shows speed relative to orbital velocity --- src/hud.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/hud.rs b/src/hud.rs index ea5b6b9..2379123 100644 --- a/src/hud.rs +++ b/src/hud.rs @@ -707,7 +707,8 @@ fn update_dashboard( fn update_speedometer( timer: ResMut, settings: Res, - q_camera: Query<&LinearVelocity, With>, + jupiter_pos: Res, + q_camera: Query<(&LinearVelocity, &Position), With>, q_player: Query<&actor::ExperiencesGForce, With>, q_target: Query<&LinearVelocity, With>, mut q_speedometer: Query<&mut Style, (With, Without)>, @@ -717,8 +718,9 @@ fn update_speedometer( if !settings.hud_active || !timer.0.just_finished() { return; } - if let Ok(cam_v) = q_camera.get_single() { - let speed = cam_v.length(); + if let Ok((cam_v, pos)) = q_camera.get_single() { + let orbital_v = nature::orbital_velocity(pos.0 - jupiter_pos.0, nature::JUPITER_MASS); + let speed = (cam_v.0 - orbital_v).length(); let speedometer_split = 5_000.0; if let Ok(mut speedometer) = q_speedometer.get_single_mut() {