mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Smooth airship movement
This commit is contained in:
parent
d3ee035449
commit
fcaf2b50d1
@ -164,15 +164,16 @@ impl Body {
|
||||
quadruped_low::Species::Lavadrake => 4.0,
|
||||
_ => 6.0,
|
||||
},
|
||||
Body::Ship(_) => 1.0,
|
||||
Body::Ship(_) => 0.1,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn can_fly(&self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
Body::BirdMedium(_) | Body::Dragon(_) | Body::BirdSmall(_) | Body::Ship(ship::Body::DefaultAirship)
|
||||
)
|
||||
pub fn can_fly(&self) -> Option<f32> {
|
||||
match self {
|
||||
Body::BirdMedium(_) | Body::Dragon(_) | Body::BirdSmall(_) => Some(1.0),
|
||||
Body::Ship(ship::Body::DefaultAirship) => Some(1.5),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn can_climb(&self) -> bool { matches!(self, Body::Humanoid(_)) }
|
||||
@ -182,8 +183,8 @@ impl Body {
|
||||
pub fn handle_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) {
|
||||
if let Some(depth) = data.physics.in_liquid {
|
||||
swim_move(data, update, efficiency, depth);
|
||||
} else if data.inputs.fly.is_pressed() && !data.physics.on_ground && data.body.can_fly() {
|
||||
fly_move(data, update, efficiency);
|
||||
} else if data.inputs.fly.is_pressed() && !data.physics.on_ground && data.body.can_fly().is_some() {
|
||||
fly_move(data, update, efficiency * data.body.can_fly().unwrap());
|
||||
} else {
|
||||
basic_move(data, update, efficiency);
|
||||
}
|
||||
|
@ -414,7 +414,7 @@ impl<'a> PhysicsSystemData<'a> {
|
||||
let old_vel = vel;
|
||||
// Integrate forces
|
||||
// Friction is assumed to be a constant dependent on location
|
||||
let friction = FRIC_AIR
|
||||
let friction = if physics_state.on_ground { 0.0 } else { FRIC_AIR }
|
||||
// .max(if physics_state.on_ground {
|
||||
// FRIC_GROUND
|
||||
// } else {
|
||||
@ -968,7 +968,9 @@ fn cylinder_voxel_collision<'a, T: BaseVol<Vox = Block> + ReadVol>(
|
||||
|
||||
if on_ground {
|
||||
physics_state.on_ground = true;
|
||||
|
||||
vel.0 = ground_vel + (vel.0 - ground_vel) * (1.0 - FRIC_GROUND.min(1.0)).powf(dt.0 * 60.0);
|
||||
physics_state.ground_vel = ground_vel;
|
||||
// If the space below us is free, then "snap" to the ground
|
||||
} else if collision_with(
|
||||
pos.0 - Vec3::unit_z() * 1.05,
|
||||
|
@ -207,7 +207,7 @@ impl<'a> System<'a> for Sys {
|
||||
in_liquid: physics_state.in_liquid.is_some(),
|
||||
min_tgt_dist: 1.0,
|
||||
can_climb: body.map(|b| b.can_climb()).unwrap_or(false),
|
||||
can_fly: body.map(|b| b.can_fly()).unwrap_or(false),
|
||||
can_fly: body.map(|b| b.can_fly().is_some()).unwrap_or(false),
|
||||
};
|
||||
|
||||
let flees = alignment
|
||||
|
Loading…
Reference in New Issue
Block a user