mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Improved climbing, block-hopping on airships
This commit is contained in:
parent
546ee48073
commit
1e9ee3d243
@ -9,12 +9,9 @@ use crate::{
|
|||||||
util::Dir,
|
util::Dir,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use vek::{
|
use vek::*;
|
||||||
vec::{Vec2, Vec3},
|
|
||||||
Lerp,
|
|
||||||
};
|
|
||||||
|
|
||||||
const HUMANOID_CLIMB_ACCEL: f32 = 5.0;
|
const HUMANOID_CLIMB_ACCEL: f32 = 24.0;
|
||||||
const CLIMB_SPEED: f32 = 5.0;
|
const CLIMB_SPEED: f32 = 5.0;
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
||||||
@ -76,26 +73,10 @@ impl CharacterBehavior for Data {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Apply Vertical Climbing Movement
|
// Apply Vertical Climbing Movement
|
||||||
if update.vel.0.z <= CLIMB_SPEED {
|
match climb {
|
||||||
match climb {
|
Climb::Down => update.vel.0.z += data.dt.0 * (GRAVITY - HUMANOID_CLIMB_ACCEL),
|
||||||
Climb::Down => {
|
Climb::Up => update.vel.0.z += data.dt.0 * (GRAVITY + HUMANOID_CLIMB_ACCEL),
|
||||||
update.vel.0 -=
|
Climb::Hold => update.vel.0.z += data.dt.0 * GRAVITY,
|
||||||
data.dt.0 * update.vel.0.map(|e| e.abs().powf(1.5) * e.signum() * 1.0);
|
|
||||||
},
|
|
||||||
Climb::Up => {
|
|
||||||
update.vel.0.z = (update.vel.0.z + data.dt.0 * GRAVITY * 1.25).min(CLIMB_SPEED);
|
|
||||||
},
|
|
||||||
Climb::Hold => {
|
|
||||||
// Antigrav
|
|
||||||
update.vel.0.z =
|
|
||||||
(update.vel.0.z + data.dt.0 * GRAVITY * 1.075).min(CLIMB_SPEED);
|
|
||||||
update.vel.0 = Lerp::lerp(
|
|
||||||
update.vel.0,
|
|
||||||
Vec3::zero(),
|
|
||||||
30.0 * data.dt.0 / (1.0 - update.vel.0.z.min(0.0) * 5.0),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
update
|
update
|
||||||
|
@ -1039,13 +1039,12 @@ fn cylinder_voxel_collision<'a, T: BaseVol<Vox = Block> + ReadVol>(
|
|||||||
// ...and we're being pushed out horizontally...
|
// ...and we're being pushed out horizontally...
|
||||||
&& resolve_dir.z == 0.0
|
&& resolve_dir.z == 0.0
|
||||||
// ...and the vertical resolution direction is sufficiently great...
|
// ...and the vertical resolution direction is sufficiently great...
|
||||||
&& -dir.z > 0.1
|
&& dir.z < -0.1
|
||||||
&& was_on_ground
|
// ...and we're falling/standing OR there is a block *directly* beneath our current origin (note: not hitbox)...
|
||||||
// // ...and we're falling/standing OR there is a block *directly* beneath our current origin (note: not hitbox)...
|
// && terrain
|
||||||
// && (vel.0.z <= 0.0 || terrain
|
|
||||||
// .get((pos.0 - Vec3::unit_z() * 0.1).map(|e| e.floor() as i32))
|
// .get((pos.0 - Vec3::unit_z() * 0.1).map(|e| e.floor() as i32))
|
||||||
// .map(|block| block.is_solid())
|
// .map(|block| block.is_solid())
|
||||||
// .unwrap_or(false))
|
// .unwrap_or(false)
|
||||||
// ...and there is a collision with a block beneath our current hitbox...
|
// ...and there is a collision with a block beneath our current hitbox...
|
||||||
&& collision_with(
|
&& collision_with(
|
||||||
pos.0 + resolve_dir - Vec3::unit_z() * 1.25,
|
pos.0 + resolve_dir - Vec3::unit_z() * 1.25,
|
||||||
@ -1129,8 +1128,8 @@ fn cylinder_voxel_collision<'a, T: BaseVol<Vox = Block> + ReadVol>(
|
|||||||
&terrain,
|
&terrain,
|
||||||
block_true,
|
block_true,
|
||||||
near_iter.clone(),
|
near_iter.clone(),
|
||||||
radius + 0.05,
|
radius,
|
||||||
z_range.start - 0.05..z_range.end + 0.05,
|
z_range.clone(),
|
||||||
) {
|
) {
|
||||||
(a + dir, true)
|
(a + dir, true)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user