mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 23:31:53 -05:00
fix stop_on_slope affecting sliding up slopes
This commit is contained in:
committed by
Rémi Verschelde
parent
84d2ef43ad
commit
0e94afbc92
@@ -1279,7 +1279,6 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const
|
|||||||
colliders.push_back(collision);
|
colliders.push_back(collision);
|
||||||
motion = collision.remainder;
|
motion = collision.remainder;
|
||||||
|
|
||||||
bool is_on_slope = false;
|
|
||||||
if (p_floor_direction == Vector2()) {
|
if (p_floor_direction == Vector2()) {
|
||||||
//all is a wall
|
//all is a wall
|
||||||
on_wall = true;
|
on_wall = true;
|
||||||
@@ -1291,7 +1290,7 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const
|
|||||||
floor_velocity = collision.collider_vel;
|
floor_velocity = collision.collider_vel;
|
||||||
|
|
||||||
if (p_stop_on_slope) {
|
if (p_stop_on_slope) {
|
||||||
if (Vector2() == lv_n + p_floor_direction) {
|
if (Vector2() == lv_n + p_floor_direction && collision.travel.length() < 1) {
|
||||||
Transform2D gt = get_global_transform();
|
Transform2D gt = get_global_transform();
|
||||||
gt.elements[2] -= collision.travel.project(p_floor_direction.tangent());
|
gt.elements[2] -= collision.travel.project(p_floor_direction.tangent());
|
||||||
set_global_transform(gt);
|
set_global_transform(gt);
|
||||||
@@ -1299,8 +1298,6 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is_on_slope = true;
|
|
||||||
|
|
||||||
} else if (collision.normal.dot(-p_floor_direction) >= Math::cos(p_floor_max_angle + FLOOR_ANGLE_THRESHOLD)) { //ceiling
|
} else if (collision.normal.dot(-p_floor_direction) >= Math::cos(p_floor_max_angle + FLOOR_ANGLE_THRESHOLD)) { //ceiling
|
||||||
on_ceiling = true;
|
on_ceiling = true;
|
||||||
} else {
|
} else {
|
||||||
@@ -1308,15 +1305,10 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_stop_on_slope && is_on_slope) {
|
|
||||||
motion = motion.slide(p_floor_direction);
|
|
||||||
lv = lv.slide(p_floor_direction);
|
|
||||||
} else {
|
|
||||||
Vector2 n = collision.normal;
|
Vector2 n = collision.normal;
|
||||||
motion = motion.slide(n);
|
motion = motion.slide(n);
|
||||||
lv = lv.slide(n);
|
lv = lv.slide(n);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (p_stop_on_slope)
|
if (p_stop_on_slope)
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user