summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2019-11-07 15:11:53 +0100
committerGitHub <noreply@github.com>2019-11-07 15:11:53 +0100
commitd596e169dcb3b652424045f3891db64445cf165a (patch)
treedfc7bd008ab1733f5fe04f03b4b3902c0882eb37
parent77816fea8bf6d05c749c9724bf1a566454d58aec (diff)
parentfead4e369a278aebc4730b04776539e31dd17898 (diff)
Merge pull request #30588 from Demiu/patch-1
Fix 3D move_and_slide with stop_on_slope
-rw-r--r--scene/3d/physics_body.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp
index a02cc4bee6..a107c3bf7a 100644
--- a/scene/3d/physics_body.cpp
+++ b/scene/3d/physics_body.cpp
@@ -1201,7 +1201,7 @@ Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Ve
if (p_stop_on_slope) {
if ((lv_n + p_floor_direction).length() < 0.01 && collision.travel.length() < 1) {
Transform gt = get_global_transform();
- gt.origin -= collision.travel;
+ gt.origin -= collision.travel.slide(p_floor_direction);
set_global_transform(gt);
return Vector3();
}
@@ -1265,7 +1265,7 @@ Vector3 KinematicBody::move_and_slide_with_snap(const Vector3 &p_linear_velocity
if (p_stop_on_slope) {
// move and collide may stray the object a bit because of pre un-stucking,
// so only ensure that motion happens on floor direction in this case.
- col.travel = p_floor_direction * p_floor_direction.dot(col.travel);
+ col.travel = col.travel.project(p_floor_direction);
}
} else {
apply = false; //snapped with floor direction, but did not snap to a floor, do not snap.