WIP crisper camera controls (implement matching velocity)
This commit is contained in:
parent
51059a2856
commit
3cef44c4b2
14
src/actor.rs
14
src/actor.rs
|
@ -823,14 +823,20 @@ fn handle_wants_acceleration(
|
|||
if let (Some(mut engine), Some(accel)) = (engine, accel) {
|
||||
let mut delta_v = DVec3::ZERO;
|
||||
let boost = engine.current_boost_factor;
|
||||
engine.currently_matching_velocity = false;
|
||||
|
||||
if accel.brake {
|
||||
if let Some(target_v) = closest_map.get(&entity) {
|
||||
**v = *target_v;
|
||||
delta_v = *target_v - v.0;
|
||||
if delta_v.length_squared() > 0.003 {
|
||||
engine.currently_matching_velocity = true;
|
||||
thruster_on = true;
|
||||
}
|
||||
} else if accel.direction != DVec3::ZERO {
|
||||
delta_v = (trans.rotation * accel.direction.as_vec3()).as_dvec3();
|
||||
}
|
||||
}
|
||||
|
||||
if accel.direction != DVec3::ZERO {
|
||||
delta_v += (trans.rotation * accel.direction.as_vec3()).as_dvec3();
|
||||
}
|
||||
|
||||
if delta_v.length_squared() > 0.003 {
|
||||
|
@ -853,7 +859,7 @@ fn handle_wants_acceleration(
|
|||
* engine.current_boost_factor;
|
||||
|
||||
// Apply acceleration to velocity
|
||||
**v += delta_v * engine_factor * dt as f64;
|
||||
**v += delta_v.normalize() * engine_factor * dt as f64;
|
||||
|
||||
// Visual effect
|
||||
if engine.engine_type == EngineType::Monopropellant {
|
||||
|
|
Loading…
Reference in a new issue