WIP crisper camera controls (fix slow acceleration (space+movement))

This commit is contained in:
yuni 2024-11-17 01:44:31 +01:00
parent 35d9f0b4fd
commit bb95469f44

View file

@ -842,8 +842,9 @@ fn handle_wants_acceleration(
if accel.brake {
if let Some(target_v) = closest_map.get(&entity) {
let stop_direction = (*target_v - v.0).as_vec3();
delta_v = (trans.rotation.inverse() * stop_direction).as_dvec3();
if delta_v.length_squared() > 0.003 {
if stop_direction.length_squared() > 0.003 {
delta_v =
(trans.rotation.inverse() * stop_direction.normalize()).as_dvec3();
engine.currently_matching_velocity = true;
thruster_on = true;
}
@ -852,7 +853,8 @@ fn handle_wants_acceleration(
if accel.direction != DVec3::ZERO {
// Player is pressing AWSD keys
delta_v += accel.direction;
let brake_factor = if accel.brake { 1.10 } else { 1.0 };
delta_v += accel.direction.normalize() * brake_factor;
} else if accel.brake {
// Player is only pressing space
allow_fullstop = true;
@ -877,9 +879,10 @@ fn handle_wants_acceleration(
* ENGINE_SPEED_FACTOR as f64
* engine.current_boost_factor;
let final_accel =
(trans.rotation * (delta_v.normalize() * engine_factor).as_vec3() * dt)
.as_dvec3();
let final_accel = (trans.rotation
* (delta_v.clamp_length_max(1.0) * engine_factor).as_vec3()
* dt)
.as_dvec3();
// Apply acceleration to velocity
if allow_fullstop {
@ -901,7 +904,7 @@ fn handle_wants_acceleration(
// Visual effect
if engine.engine_type == EngineType::Monopropellant {
let thruster_direction = delta_v.normalize();
let thruster_direction = final_accel.normalize();
let thruster_pos = pos.0 - 0.3 * thruster_direction;
let thruster_v = v.0 - boost * 5.0 * thruster_direction;
ew_effect.send(visual::SpawnEffectEvent {