Fix loss of glider control when falling perfectly vertically

This commit is contained in:
Ludvig Böklin 2021-04-24 20:32:45 +02:00
parent 0810d8920f
commit 94b1d37fb7

View File

@ -64,6 +64,7 @@ impl CharacterBehavior for Data {
.and_then(|tgt_dir| {
Dir::from_unnormalized(data.vel.0)
.and_then(|moving_dir| moving_dir.to_horizontal())
.or_else(|| self.ori.look_dir().to_horizontal())
.map(|moving_dir| {
Ori::from(tgt_dir).rolled_right(
(1.0 - moving_dir.dot(*tgt_dir).max(0.0))