stop key now breaks with proper engine physics
This commit is contained in:
parent
add6605a9a
commit
ac747ac9c3
|
@ -109,17 +109,21 @@ fn run_camera_controller(
|
|||
let mut engine = if let Ok(engine) = q_engine.get_single_mut() { engine } else { player_engine };
|
||||
|
||||
// Apply movement update
|
||||
let acceleration_camera: Vec3;
|
||||
let mut acceleration_camera: Vec3;
|
||||
if axis_input != Vec3::ZERO {
|
||||
acceleration_camera = axis_input.normalize();
|
||||
engine.current_warmup = (engine.current_warmup + dt / engine.warmup_seconds).clamp(0.0, 1.0);
|
||||
play_thruster_sound = !settings.mute_sfx;
|
||||
acceleration_camera = axis_input;
|
||||
} else {
|
||||
acceleration_camera = Vec3::ZERO;
|
||||
engine.current_warmup = (engine.current_warmup - dt / engine.warmup_seconds).clamp(0.0, 1.0);
|
||||
}
|
||||
|
||||
let forward_factor = engine.current_warmup * (if axis_input.z < 0.0 {
|
||||
if key_input.pressed(settings.key_stop) {
|
||||
let stop_direction = -actor.v.normalize();
|
||||
if stop_direction.length_squared() > 0.3 {
|
||||
acceleration_camera += transform.rotation.inverse() * stop_direction;
|
||||
}
|
||||
}
|
||||
|
||||
let forward_factor = engine.current_warmup * (if acceleration_camera.z < 0.0 {
|
||||
engine.thrust_forward
|
||||
} else {
|
||||
engine.thrust_back
|
||||
|
@ -128,10 +132,20 @@ fn run_camera_controller(
|
|||
let up_factor = engine.thrust_sideways * engine.current_warmup;
|
||||
let factor = Vec3::new(right_factor, up_factor, forward_factor);
|
||||
|
||||
let acceleration_global = transform.rotation * (acceleration_camera * factor);
|
||||
if acceleration_camera.length_squared() > 0.3 {
|
||||
let acceleration_global = transform.rotation * (acceleration_camera.normalize() * factor);
|
||||
dbg!(acceleration_camera);
|
||||
dbg!(acceleration_global);
|
||||
|
||||
let speed_multiplier = 30.0;
|
||||
actor.v += speed_multiplier * dt * acceleration_global;
|
||||
let speed_multiplier = 30.0;
|
||||
actor.v += speed_multiplier * dt * acceleration_global;
|
||||
|
||||
engine.current_warmup = (engine.current_warmup + dt / engine.warmup_seconds).clamp(0.0, 1.0);
|
||||
play_thruster_sound = !settings.mute_sfx;
|
||||
}
|
||||
else {
|
||||
engine.current_warmup = (engine.current_warmup - dt / engine.warmup_seconds).clamp(0.0, 1.0);
|
||||
}
|
||||
|
||||
// Handle mouse input
|
||||
let mut mouse_delta = Vec2::ZERO;
|
||||
|
|
Loading…
Reference in a new issue