dimforge / rapier

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

KinematicCharacterController min_slope_slide_angle does not send any information to output when slope angle is larger than min_slope_slide_angle #465

Closed Jeff425 closed 1 year ago

Jeff425 commented 1 year ago

Why is this an issue? The KinematicCharacterController has a field min_slope_slide_angle that when set, it should make entities that are on steeper slopes to slide down. While the handle_slopes function here https://github.com/dimforge/rapier/blob/c85a833d3a2e4c66024627a9745f033fbbee283a/src/control/character_controller.rs#L475 does do that, it does not send any information to the consumer that it is sliding down a slope. As a consumer, there needs to be a way to know if an entity is currently sliding down a slope in order to maintain things like gravity acceleration.

Potential fix: Add an extra boolean flag such as is_sliding_down_slope to the KinematicCharacterControllerOutput when https://github.com/dimforge/rapier/blob/c85a833d3a2e4c66024627a9745f033fbbee283a/src/control/character_controller.rs#L498 is reached.

sebcrozet commented 1 year ago

I don’t think we should change the meaning of the grounded flag to add some special-case. Instead, we could add another flag is_sliding_down_slope that would be set to true in the case you are describing.

Jeff425 commented 1 year ago

Oh yeah that works as a more generic solution. I'll update the issue

stefnotch commented 1 year ago

@Jeff425 Would you mind turning your solution into a lovely pull request?

We're suffering from the same issue in our jumping logic, basically a player in our game should only be able to jump if they're grounded and if they're not sliding down a slope.

Jeff425 commented 1 year ago

Yes I will do that today