diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-11-20 07:58:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-20 07:58:44 +0100 |
commit | 360343fb5a09a02df2774712c3730a20c9a4d26d (patch) | |
tree | 7ff1c718a440cc0f63e50f1bedcca2168d9821d4 | |
parent | ebdf9cee6b87ab9cffa05d771889fac8ca38f19f (diff) | |
parent | 7dd9e5c57cec3d93ab6a359559d5a79e87d5bf4a (diff) |
Merge pull request #13065 from DoctorAlpaca/master
Fix the prevention for sliding on slopes in the 2d version of move_and_slide
-rw-r--r-- | scene/2d/physics_body_2d.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index 1287a800e3..1f6127e6eb 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -1028,7 +1028,10 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const on_floor = true; floor_velocity = collision.collider_vel; - if (collision.travel.length() < 1 && ABS((lv.x - floor_velocity.x)) < p_slope_stop_min_velocity) { + Vector2 rel_v = lv - floor_velocity; + Vector2 hv = rel_v - p_floor_direction * p_floor_direction.dot(rel_v); + + if (collision.travel.length() < 1 && hv.length() < p_slope_stop_min_velocity) { Transform2D gt = get_global_transform(); gt.elements[2] -= collision.travel; set_global_transform(gt); |