Fix uncontrolled sliding
This commit is contained in:
@@ -485,8 +485,10 @@ impl KinematicCharacterController {
|
|||||||
translation_remaining: &Vector<Real>,
|
translation_remaining: &Vector<Real>,
|
||||||
offset: Real,
|
offset: Real,
|
||||||
) -> Option<Vector<Real>> {
|
) -> Option<Vector<Real>> {
|
||||||
|
let [vertical_translation, horizontal_translation] =
|
||||||
|
self.split_into_components(translation_remaining);
|
||||||
let [vertical_slope_translation, horizontal_slope_translation] =
|
let [vertical_slope_translation, horizontal_slope_translation] =
|
||||||
self.split_into_components(translation_remaining)
|
[vertical_translation, horizontal_translation]
|
||||||
.map(|remaining| subtract_hit(remaining, hit, offset));
|
.map(|remaining| subtract_hit(remaining, hit, offset));
|
||||||
let slope_translation = horizontal_slope_translation + vertical_slope_translation;
|
let slope_translation = horizontal_slope_translation + vertical_slope_translation;
|
||||||
|
|
||||||
@@ -496,10 +498,10 @@ impl KinematicCharacterController {
|
|||||||
|
|
||||||
climbing
|
climbing
|
||||||
.then(||(angle_with_floor <= self.max_slope_climb_angle) // Are we allowed to climb?
|
.then(||(angle_with_floor <= self.max_slope_climb_angle) // Are we allowed to climb?
|
||||||
.then_some(slope_translation))
|
.then_some(horizontal_translation ))
|
||||||
.unwrap_or_else(|| (angle_with_floor >= self.min_slope_slide_angle)// Are we allowed to slide?
|
.unwrap_or_else(|| (angle_with_floor >= self.min_slope_slide_angle)// Are we allowed to slide?
|
||||||
.then_some(slope_translation)
|
.then_some(slope_translation )
|
||||||
.unwrap_or(horizontal_slope_translation)
|
.unwrap_or(horizontal_translation)
|
||||||
.into())
|
.into())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user