mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
swim now uses handle_orientation fn
This commit is contained in:
parent
ae175e57f3
commit
cb04df7736
@ -81,7 +81,7 @@ impl CharacterBehavior for Data {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
handle_orientation(data, &mut update);
|
handle_orientation(data, &mut update, 10.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handling attacking
|
// Handling attacking
|
||||||
|
@ -53,10 +53,10 @@ fn basic_move(data: &JoinData, update: &mut StateUpdate) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_orientation(data, update);
|
handle_orientation(data, update, 9.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_orientation(data: &JoinData, update: &mut StateUpdate) {
|
pub fn handle_orientation(data: &JoinData, update: &mut StateUpdate, strength: f32) {
|
||||||
// Set direction based on move direction
|
// Set direction based on move direction
|
||||||
let ori_dir = if update.character.is_attack() || update.character.is_block() {
|
let ori_dir = if update.character.is_attack() || update.character.is_block() {
|
||||||
Vec2::from(data.inputs.look_dir).normalized()
|
Vec2::from(data.inputs.look_dir).normalized()
|
||||||
@ -69,7 +69,7 @@ pub fn handle_orientation(data: &JoinData, update: &mut StateUpdate) {
|
|||||||
&& (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared()
|
&& (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared()
|
||||||
> 0.001
|
> 0.001
|
||||||
{
|
{
|
||||||
update.ori.0 = vek::ops::Slerp::slerp(update.ori.0, ori_dir.into(), 9.0 * data.dt.0);
|
update.ori.0 = vek::ops::Slerp::slerp(update.ori.0, ori_dir.into(), strength * data.dt.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,23 +84,7 @@ fn swim_move(data: &JoinData, update: &mut StateUpdate) {
|
|||||||
0.0
|
0.0
|
||||||
};
|
};
|
||||||
|
|
||||||
// Set direction based on move direction when on the ground
|
handle_orientation(data, update, if data.physics.on_ground { 9.0 } else { 2.0 });
|
||||||
let ori_dir = if update.character.is_attack() || update.character.is_block() {
|
|
||||||
Vec2::from(data.inputs.look_dir).normalized()
|
|
||||||
} else {
|
|
||||||
Vec2::from(update.vel.0)
|
|
||||||
};
|
|
||||||
|
|
||||||
if ori_dir.magnitude_squared() > 0.0001
|
|
||||||
&& (update.ori.0.normalized() - Vec3::from(ori_dir).normalized()).magnitude_squared()
|
|
||||||
> 0.001
|
|
||||||
{
|
|
||||||
update.ori.0 = vek::ops::Slerp::slerp(
|
|
||||||
update.ori.0,
|
|
||||||
ori_dir.into(),
|
|
||||||
if data.physics.on_ground { 9.0 } else { 2.0 } * data.dt.0,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Force players to pulse jump button to swim up
|
// Force players to pulse jump button to swim up
|
||||||
if data.inputs.jump.is_pressed() && !data.inputs.jump.is_long_press(Duration::from_millis(600))
|
if data.inputs.jump.is_pressed() && !data.inputs.jump.is_long_press(Duration::from_millis(600))
|
||||||
|
Loading…
Reference in New Issue
Block a user