mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Make character upright itself even while idle
This commit is contained in:
parent
92b32b4c36
commit
cbd7c4481c
@ -349,10 +349,10 @@ pub fn handle_forced_movement(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_orientation(data: &JoinData<'_>, update: &mut StateUpdate, efficiency: f32) {
|
pub fn handle_orientation(data: &JoinData<'_>, update: &mut StateUpdate, efficiency: f32) {
|
||||||
if let Some(dir) = (is_strafing(data, update) || update.character.is_attack())
|
let dir = (is_strafing(data, update) || update.character.is_attack())
|
||||||
.then(|| data.inputs.look_dir.to_horizontal().unwrap_or_default())
|
.then(|| data.inputs.look_dir.to_horizontal().unwrap_or_default())
|
||||||
.or_else(|| Dir::from_unnormalized(data.inputs.move_dir.into()))
|
.or_else(|| Dir::from_unnormalized(data.inputs.move_dir.into()))
|
||||||
{
|
.unwrap_or_else(|| data.ori.to_horizontal().look_dir());
|
||||||
let rate = {
|
let rate = {
|
||||||
let angle = update.ori.look_dir().angle_between(*dir);
|
let angle = update.ori.look_dir().angle_between(*dir);
|
||||||
data.body.base_ori_rate() * efficiency * std::f32::consts::PI / angle
|
data.body.base_ori_rate() * efficiency * std::f32::consts::PI / angle
|
||||||
@ -360,7 +360,6 @@ pub fn handle_orientation(data: &JoinData<'_>, update: &mut StateUpdate, efficie
|
|||||||
update.ori = update
|
update.ori = update
|
||||||
.ori
|
.ori
|
||||||
.slerped_towards(dir.into(), (data.dt.0 * rate).min(1.0));
|
.slerped_towards(dir.into(), (data.dt.0 * rate).min(1.0));
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates components to move player as if theyre swimming
|
/// Updates components to move player as if theyre swimming
|
||||||
|
Loading…
x
Reference in New Issue
Block a user