Fix erroneous sliding
This commit is contained in:
@@ -499,16 +499,20 @@ impl KinematicCharacterController {
|
|||||||
let angle_with_floor = self.up.angle(&hit.normal1);
|
let angle_with_floor = self.up.angle(&hit.normal1);
|
||||||
let climbing = self.up.dot(&slope_translation) >= 0.0;
|
let climbing = self.up.dot(&slope_translation) >= 0.0;
|
||||||
|
|
||||||
if climbing {
|
climbing
|
||||||
// Are we allowed to climb?
|
.then(|| {
|
||||||
(angle_with_floor <= self.max_slope_climb_angle).then_some(slope_translation)
|
(angle_with_floor <= self.max_slope_climb_angle) // Are we allowed to climb?
|
||||||
}
|
.then_some(horizontal_translation)
|
||||||
// Are we forced to slide?
|
})
|
||||||
else if angle_with_floor >= self.min_slope_slide_angle {
|
.unwrap_or_else(|| {
|
||||||
slope_translation.into()
|
// Are we allowed to slide?
|
||||||
} else {
|
if angle_with_floor >= self.min_slope_slide_angle {
|
||||||
horizontal_translation.into()
|
slope_translation
|
||||||
}
|
} else {
|
||||||
|
horizontal_translation
|
||||||
|
}
|
||||||
|
.into()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn split_into_components(&self, translation: &Vector<Real>) -> [Vector<Real>; 2] {
|
fn split_into_components(&self, translation: &Vector<Real>) -> [Vector<Real>; 2] {
|
||||||
|
|||||||
Reference in New Issue
Block a user