dimforge / rapier

2D and 3D physics engines focused on performance.
https://rapier.rs
Apache License 2.0
3.77k stars 235 forks source link

fix: character controller: walls less likely to trigger ground detection #655

Closed Vrixyz closed 2 weeks ago

Vrixyz commented 2 weeks ago

Context

While trying out https://github.com/dimforge/bevy_rapier/pull/476 ; I noticed I could jump when hitting walls (particularly on the junction of 2 walls).

Bug analysis

When printing the normal dot value, I had this value in air: 1.7037166e-5 (hitting a wall perfectly perpendicular)

The current epsilon being 1.0e-5 ; this dot check is true, then is_grounded is true, and the character can jump in the example from https://github.com/dimforge/bevy_rapier/pull/476.

Solution decription

I think it makes sense to relax this epsilon ; alternatively we could:

But that first fix is probably an easy sufficient fix ?

I'm wondering if this has anything to do with scaled transforms ?

sebcrozet commented 2 weeks ago

For the record, bumping the epsilon to 1.0e-3 means that for the controller to be grounded, the angle between the contact normal and the up vector has to be smaller than 89.9427042 degrees (instead of 89.999427 when the epsilon was 1.0e-5). That sounds reasonable.