From add6605a9a9685905fb7d50d43184554161ee754 Mon Sep 17 00:00:00 2001 From: hut Date: Fri, 29 Mar 2024 01:55:23 +0100 Subject: [PATCH] WIP stop key 2 --- src/camera.rs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/camera.rs b/src/camera.rs index 46001ef..3a82b8e 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -81,10 +81,10 @@ fn run_camera_controller( let mut axis_input = Vec3::ZERO; if focused { if key_input.pressed(settings.key_forward) { - axis_input.z += 1.0; + axis_input.z -= 1.0; } if key_input.pressed(settings.key_back) { - axis_input.z -= 1.0; + axis_input.z += 1.0; } if key_input.pressed(settings.key_right) { axis_input.x += 1.0; @@ -119,22 +119,16 @@ fn run_camera_controller( engine.current_warmup = (engine.current_warmup - dt / engine.warmup_seconds).clamp(0.0, 1.0); } - let forward = *transform.forward(); - let right = *transform.right(); - let up = *transform.up(); - - let forward_factor = engine.current_warmup * (if axis_input.z > 0.0 { + let forward_factor = engine.current_warmup * (if axis_input.z < 0.0 { engine.thrust_forward } else { engine.thrust_back }); let right_factor = engine.thrust_sideways * engine.current_warmup; let up_factor = engine.thrust_sideways * engine.current_warmup; + let factor = Vec3::new(right_factor, up_factor, forward_factor); - let acceleration_global - = acceleration_camera.x * right * right_factor - + acceleration_camera.y * up * up_factor - + acceleration_camera.z * forward * forward_factor; + let acceleration_global = transform.rotation * (acceleration_camera * factor); let speed_multiplier = 30.0; actor.v += speed_multiplier * dt * acceleration_global;