aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Nils Ferner <contact@jnferner.com>2023-01-28 00:30:20 +0100
committerJan Nils Ferner <contact@jnferner.com>2023-01-28 00:30:20 +0100
commite3fb4f71350a448eb5fa08b7b134d219d082d2c3 (patch)
tree188e40ad9803f72f9f08a41968256496f95e0b25 /src
parent1a94c62a1aa5de0eedaf796f7dd5d81ce3c0ad2b (diff)
downloadrapier-e3fb4f71350a448eb5fa08b7b134d219d082d2c3.tar.gz
rapier-e3fb4f71350a448eb5fa08b7b134d219d082d2c3.tar.bz2
rapier-e3fb4f71350a448eb5fa08b7b134d219d082d2c3.zip
Move main ground detection duty to snapping to ground
Diffstat (limited to 'src')
-rw-r--r--src/control/character_controller.rs27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/control/character_controller.rs b/src/control/character_controller.rs
index 438eab1..40338bb 100644
--- a/src/control/character_controller.rs
+++ b/src/control/character_controller.rs
@@ -193,8 +193,8 @@ impl KinematicCharacterController {
let mut translation_remaining = desired_translation;
- // Check if we are grounded at the initial position.
- let grounded_at_starting_pos = self.detect_grounded_status_and_apply_friction(
+ // Apply friction
+ self.detect_grounded_status_and_apply_friction(
dt,
bodies,
colliders,
@@ -299,18 +299,17 @@ impl KinematicCharacterController {
}
// 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,
- );
- }
+ self.snap_to_ground(
+ bodies,
+ colliders,
+ queries,
+ character_shape,
+ &(Translation::from(result.translation) * character_pos),
+ &dims,
+ filter,
+ &mut result,
+ );
+
// Return the result.
result