Skip to content

Commit

Permalink
Merge pull request #13065 from DoctorAlpaca/master
Browse files Browse the repository at this point in the history
Fix the prevention for sliding on slopes in the 2d version of move_and_slide
  • Loading branch information
akien-mga authored Nov 20, 2017
2 parents ebdf9ce + 7dd9e5c commit 360343f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion scene/2d/physics_body_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 360343f

Please sign in to comment.