diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-11-09 17:31:29 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-11-09 17:32:50 -0300 |
commit | 0416ca2fd22506689cd93e00fe6bd61e4e0841d1 (patch) | |
tree | 30e29bd113a63c9d8f2d31f4968fff9e9e208325 | |
parent | 50a9bd4e23e62579e2249de3c27624d6c56df1d0 (diff) |
Add slope min stop velocity on 3D physics body, closes #10981
-rw-r--r-- | scene/3d/physics_body.cpp | 9 |
1 files 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 { |