diff options
| author | Jan Hohenheim <jan@hohenheim.ch> | 2023-02-04 19:41:01 +0100 |
|---|---|---|
| committer | Jan Hohenheim <jan@hohenheim.ch> | 2023-02-04 19:41:01 +0100 |
| commit | b461d028df09f8715646ca476e30693121777f31 (patch) | |
| tree | 1f0e61d66f1b3cfd0c623cc45a05de91d77ce92e | |
| parent | 6c5713aa0c8317e2ac428a546ae1ff0e1445e1e1 (diff) | |
| download | rapier-b461d028df09f8715646ca476e30693121777f31.tar.gz rapier-b461d028df09f8715646ca476e30693121777f31.tar.bz2 rapier-b461d028df09f8715646ca476e30693121777f31.zip | |
Remove overzealous ground-snapping
| -rw-r--r-- | src/control/character_controller.rs | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/control/character_controller.rs b/src/control/character_controller.rs index 24ccc6c..5812d2e 100644 --- a/src/control/character_controller.rs +++ b/src/control/character_controller.rs @@ -193,7 +193,7 @@ impl KinematicCharacterController { let mut translation_remaining = desired_translation; - self.detect_grounded_status_and_apply_friction( + let grounded_at_starting_pos = self.detect_grounded_status_and_apply_friction( dt, bodies, colliders, @@ -294,18 +294,19 @@ impl KinematicCharacterController { break; } } - - // If needed, snap to the ground. - self.snap_to_ground( - bodies, - colliders, - queries, - character_shape, - &(Translation::from(result.translation) * character_pos), - &dims, - filter, - &mut result, - ); + // If needed, and if we are not already grounded, snap to the ground. + if grounded_at_starting_pos { + self.snap_to_ground( + bodies, + colliders, + queries, + character_shape, + &(Translation::from(result.translation) * character_pos), + &dims, + filter, + &mut result, + ); + } // Return the result. result |
