From 0416ca2fd22506689cd93e00fe6bd61e4e0841d1 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Thu, 9 Nov 2017 17:31:29 -0300 Subject: Add slope min stop velocity on 3D physics body, closes #10981 --- scene/3d/physics_body.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp index df137f1908..362421a534 100644 --- a/scene/3d/physics_body.cpp +++ b/scene/3d/physics_body.cpp @@ -988,12 +988,15 @@ Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Ve on_floor = true; floor_velocity = collision.collider_vel; - /*if (collision.travel.length() < 0.01 && ABS((lv.x - floor_velocity.x)) < p_slope_stop_min_velocity) { + Vector3 rel_v = lv - floor_velocity; + Vector3 hv = rel_v - p_floor_direction * p_floor_direction.dot(rel_v); + + if (collision.travel.length() < 0.05 && hv.length() < p_slope_stop_min_velocity) { Transform gt = get_global_transform(); - gt.elements[2] -= collision.travel; + gt.origin -= collision.travel; set_global_transform(gt); return Vector3(); - }*/ + } } else if (collision.normal.dot(-p_floor_direction) >= Math::cos(p_floor_max_angle)) { //ceiling on_ceiling = true; } else { -- cgit v1.2.3