WIP stop key 2

This commit is contained in:
yuni 2024-03-29 01:55:23 +01:00
parent 65c843f55f
commit add6605a9a

View file

@ -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;