Skip to content

Commit 567b9f5

Browse files
Fix missing plane (#900)
Thanks, parry --------- Co-authored-by: Joona Aalto <jondolf.dev@gmail.com>
1 parent 986c2bb commit 567b9f5

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/character_controller/move_and_slide.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ impl<'w, 's> MoveAndSlide<'w, 's> {
515515
position += sweep;
516516
break;
517517
};
518+
let point = sweep_hit.point2 + position;
518519

519520
// Move up to the hit point.
520521
time_left -= time_left * (sweep_hit.distance / distance);
@@ -524,6 +525,21 @@ impl<'w, 's> MoveAndSlide<'w, 's> {
524525
// This often includes a ground plane.
525526
let mut planes: Vec<Dir> = config.planes.clone();
526527

528+
// We need to add the sweep hit's plane explicitly, as `contact_manifolds` sometimes returns nothing
529+
// due to a Parry bug. Otherwise, `contact_manifolds` would pick up this normal anyways.
530+
// TODO: Remove this once the collision bug is fixed.
531+
if on_hit(MoveAndSlideHitData {
532+
entity: sweep_hit.entity,
533+
point,
534+
normal: &mut Dir::new_unchecked(sweep_hit.normal1.f32()),
535+
collision_distance: sweep_hit.collision_distance,
536+
distance: sweep_hit.distance,
537+
position: &mut position,
538+
velocity: &mut velocity,
539+
}) {
540+
planes.push(Dir::new_unchecked(sweep_hit.normal1.f32()));
541+
}
542+
527543
// Collect contact planes.
528544
self.intersections(
529545
shape,

0 commit comments

Comments
 (0)