From 84b66d63e39cb6182974b8f674684748c7c4d594 Mon Sep 17 00:00:00 2001 From: Thierry Berger Date: Mon, 17 Jun 2024 16:51:06 +0200 Subject: fix: character controller: walls less likely to trigger ground detection (#655) --- src/control/character_controller.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/control/character_controller.rs') diff --git a/src/control/character_controller.rs b/src/control/character_controller.rs index dc7381f..2332bc3 100644 --- a/src/control/character_controller.rs +++ b/src/control/character_controller.rs @@ -519,7 +519,9 @@ impl KinematicCharacterController { ) -> bool { let normal = -(character_pos * manifold.local_n1); - if normal.dot(&self.up) >= 1.0e-5 { + // For the controller to be grounded, the angle between the contact normal and the up vector + // has to be smaller than acos(1.0e-3) = 89.94 degrees. + if normal.dot(&self.up) >= 1.0e-3 { let prediction = self.predict_ground(dims.y); for contact in &manifold.points { if contact.dist <= prediction { -- cgit