Skip to content

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

Merged
ThierryBerger merged 2 commits intodimforge:masterfrom
ThierryBerger:fix-character-controller-grounded-epsilon
Jun 17, 2024
Merged

fix: character controller: walls less likely to trigger ground detection#655
ThierryBerger merged 2 commits intodimforge:masterfrom
ThierryBerger:fix-character-controller-grounded-epsilon

Conversation

@ThierryBerger
Copy link
Copy Markdown
Contributor

@ThierryBerger ThierryBerger commented Jun 16, 2024

Context

While trying out dimforge/bevy_rapier#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 dimforge/bevy_rapier#476.

Solution decription

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

  • reuse the slope authorized for the character
  • or really pump that value, and/or normalize it
  • make it configurable

But that first fix is probably an easy sufficient fix ?

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

@ThierryBerger ThierryBerger changed the title fix: walls less likely to trigger ground detection fix: character controller: walls less likely to trigger ground detection Jun 16, 2024
@ThierryBerger ThierryBerger requested a review from sebcrozet June 17, 2024 07:45
@sebcrozet
Copy link
Copy Markdown
Member

sebcrozet commented Jun 17, 2024

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.

@ThierryBerger ThierryBerger merged commit 84b66d6 into dimforge:master Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants