From d5cd4fe4bc36feaae40a41f0d07d8bffae4383d5 Mon Sep 17 00:00:00 2001 From: Jan Nils Ferner Date: Thu, 26 Jan 2023 23:54:51 +0100 Subject: Only apply snap if necessary --- src/control/character_controller.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/control') diff --git a/src/control/character_controller.rs b/src/control/character_controller.rs index 8fb4b7f..ef8973c 100644 --- a/src/control/character_controller.rs +++ b/src/control/character_controller.rs @@ -342,7 +342,10 @@ impl KinematicCharacterController { filter, ) { // Apply the snap. - result.translation -= *self.up * (hit.toi - offset); + let snap_distance = hit.toi - offset; + if snap_distance.abs() > 1.0e-5 { + result.translation -= *self.up * snap_distance; + } result.grounded = true; return Some((hit_handle, hit)); } -- cgit