-
-
Notifications
You must be signed in to change notification settings - Fork 261
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
I guess kind of reworking the controller to not have the speed loss in the first place is not really possible? Would that result in loads of loop iterations of the slope sweeps? I am asking because technically this behavior of slowing down/speeding up on slopes is not what one would expect from a character controller, especially contradicting the "kinematic" keyword. Same as the concept of "friction", it should usually always be infinite or zero. For slopes specifically, the expectation (subjectively) is that one can climb them at full speed and descend them at full speed, unless the angle exceeds the maximum angle, then slipping is involved in some way. My problem currently also is that I can't control which slopes to climb as the effect of the slope angles is too high, while also causing considerate CPU load (the loop that does the offset by the normal nudge and then raytraces again). So, TLDR: This sounds like it solves problems of an actual dynamic character controller, not a kinematic one and properly getting that kinematic behavior may involve going back to the drawing board Edit: Maybe it's a "simple" matter of gravity as well, because when I stopped applying gravity to the "input", I got a much better behavior at sliding (of course you can't drop down then), but obviously that fails on downward slopes. I'll try to see if I can do something about that just by conditionally having gravity on when not on ground or something. Edit 2: The more I think about it it's related to manually applying gravity (I sure hope I copied that from some example), because the code in |
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