mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fixed weird fall damage application
This commit is contained in:
parent
65c0e224a6
commit
f00f96636c
@ -1605,10 +1605,6 @@ fn box_voxel_collision<T: BaseVol<Vox = Block> + ReadVol>(
|
|||||||
on_ceiling = true;
|
on_ceiling = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if resolve_dir.magnitude_squared() > 0.0 {
|
|
||||||
land_on_ground(entity, *vel, resolve_dir.normalized());
|
|
||||||
}
|
|
||||||
|
|
||||||
// When the resolution direction is non-vertical, we must be colliding
|
// When the resolution direction is non-vertical, we must be colliding
|
||||||
// with a wall
|
// with a wall
|
||||||
//
|
//
|
||||||
@ -1652,7 +1648,10 @@ fn box_voxel_collision<T: BaseVol<Vox = Block> + ReadVol>(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If not, correct the velocity
|
// If not, correct the velocity, applying collision damage as we do
|
||||||
|
if resolve_dir.magnitude_squared() > 0.0 {
|
||||||
|
land_on_ground(entity, *vel, resolve_dir.normalized());
|
||||||
|
}
|
||||||
vel.0 = vel.0.map2(
|
vel.0 = vel.0.map2(
|
||||||
resolve_dir,
|
resolve_dir,
|
||||||
|e, d| {
|
|e, d| {
|
||||||
|
@ -603,7 +603,18 @@ pub fn handle_land_on_ground(
|
|||||||
) {
|
) {
|
||||||
let ecs = server.state.ecs();
|
let ecs = server.state.ecs();
|
||||||
|
|
||||||
let relative_vel = vel.dot(-surface_normal);
|
// HACK: Certain ability movements currently take up above the fall damage
|
||||||
|
// threshold in the horizontal axis. This factor dampens velocity in the
|
||||||
|
// horizontal axis when applying fall damage.
|
||||||
|
let horizontal_damp = 0.5
|
||||||
|
+ vel
|
||||||
|
.try_normalized()
|
||||||
|
.unwrap_or_default()
|
||||||
|
.dot(Vec3::unit_z())
|
||||||
|
.abs()
|
||||||
|
* 0.5;
|
||||||
|
|
||||||
|
let relative_vel = vel.dot(-surface_normal) * horizontal_damp;
|
||||||
|
|
||||||
// The second part of this if statement disables all fall damage when in the
|
// The second part of this if statement disables all fall damage when in the
|
||||||
// water. This was added as a *temporary* fix a bug that causes you to take
|
// water. This was added as a *temporary* fix a bug that causes you to take
|
||||||
|
Loading…
Reference in New Issue
Block a user