diff --git a/common/src/sys/phys.rs b/common/src/sys/phys.rs index d57ef92df1..29242556d4 100644 --- a/common/src/sys/phys.rs +++ b/common/src/sys/phys.rs @@ -117,7 +117,12 @@ impl<'a> System<'a> for Sys { } else { 0.0 }); - let downward_force = if physics_state.in_fluid { + let in_loaded_chunk = terrain + .get_key(terrain.pos_key(pos.0.map(|e| e.floor() as i32))) + .is_some(); + let downward_force = if !in_loaded_chunk { + 0.0 // No gravity in unloaded chunks + } else if physics_state.in_fluid { (1.0 - BOUYANCY) * GRAVITY } else { GRAVITY @@ -125,10 +130,7 @@ impl<'a> System<'a> for Sys { vel.0 = integrate_forces(dt.0, vel.0, downward_force, friction); // Don't move if we're not in a loaded chunk - let mut pos_delta = if terrain - .get_key(terrain.pos_key(pos.0.map(|e| e.floor() as i32))) - .is_some() - { + let mut pos_delta = if in_loaded_chunk { // this is an approximation that allows most framerates to // behave in a similar manner. let dt_lerp = 0.2; @@ -319,6 +321,7 @@ impl<'a> System<'a> for Sys { } if attempts == MAX_ATTEMPTS { + vel.0 = Vec3::zero(); pos.0 = old_pos; break; }