Skip to content
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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ntibi
Copy link

@ntibi ntibi commented Dec 17, 2023

Adds reapply_lost_speed: bool to KinematicCharacterController

When 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

Comment on lines 275 to 320
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;
}
}
Copy link
Contributor

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 ?)

Copy link
Author

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

@ntibi ntibi closed this Aug 3, 2024
@ntibi ntibi reopened this Aug 3, 2024
@ntibi ntibi marked this pull request as draft August 3, 2024 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants