Keep character standing up while on ground

This commit is contained in:
Ludvig Böklin 2021-06-04 18:11:21 +02:00
parent 87afb58f73
commit 1c1b0b0a8e

View File

@ -337,6 +337,11 @@ pub fn handle_orientation(data: &JoinData, update: &mut StateUpdate, efficiency:
if let Some(dir) = (is_strafing(data, update) || update.character.is_attack())
.then(|| data.inputs.look_dir.to_horizontal().unwrap_or_default())
.or_else(|| Dir::from_unnormalized(data.inputs.move_dir.into()))
.or_else(|| {
data.physics
.on_ground
.then_some(data.ori.look_dir().to_horizontal().unwrap_or_default())
})
{
let rate = {
let angle = update.ori.look_dir().angle_between(*dir);
@ -345,7 +350,7 @@ pub fn handle_orientation(data: &JoinData, update: &mut StateUpdate, efficiency:
update.ori = update
.ori
.slerped_towards(dir.into(), (data.dt.0 * rate).min(1.0));
};
}
}
/// Updates components to move player as if theyre swimming