-
-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add reapply_lost_speed to KinematicCharacterController #569
base: master
Are you sure you want to change the base?
Conversation
src/control/character_controller.rs
Outdated
if self.slide && self.reapply_lost_speed { | ||
let diff = | ||
pre_slide_translation_remaining.norm() - translation_remaining.norm(); | ||
if let Some((normalized_dir, _)) = | ||
// threshold has to be > subtract_hit hardcoded correction, if not, we get made up movement in the direction of the hit normal | ||
UnitVector::try_new_and_get(translation_remaining, 1.0e-4) | ||
{ | ||
// reapply the lost speed (but in the corrected direction) | ||
translation_remaining += *normalized_dir * diff; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That condition should probably be in case there is no stairs ? otherwise we might end up intersecting with the stair. (and it might result in not going up the stair, or worse an infinite loop ?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed, but even with the reapply in the if !self.handle_stairs
, reapplying the speed can be slightly flaky, especially in 3d
im turning the PR back into a draft and looking into it
0c8a7c0
to
617428e
Compare
Adds
reapply_lost_speed: bool
to KinematicCharacterControllerWhen set to true, the velocity lost by sliding will be reapplied to the corrected direction
so the character moves at the same speed wether it's sliding or not