Ensure move and slide snap respects stop on slope, fixes #26180
This commit is contained in:
parent
24097811e4
commit
9dfe3b6d9e
2 changed files with 11 additions and 0 deletions
|
@ -1341,6 +1341,12 @@ Vector2 KinematicBody2D::move_and_slide_with_snap(const Vector2 &p_linear_veloci
|
||||||
on_floor = true;
|
on_floor = true;
|
||||||
on_floor_body = col.collider_rid;
|
on_floor_body = col.collider_rid;
|
||||||
floor_velocity = col.collider_vel;
|
floor_velocity = col.collider_vel;
|
||||||
|
if (p_stop_on_slope) {
|
||||||
|
// move and collide may stray the object a bit because of pre un-stucking,
|
||||||
|
// so only ensure that motion happens on floor direction in this case.
|
||||||
|
col.travel = p_floor_direction * p_floor_direction.dot(col.travel);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
apply = false;
|
apply = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1288,6 +1288,11 @@ Vector3 KinematicBody::move_and_slide_with_snap(const Vector3 &p_linear_velocity
|
||||||
on_floor = true;
|
on_floor = true;
|
||||||
on_floor_body = col.collider_rid;
|
on_floor_body = col.collider_rid;
|
||||||
floor_velocity = col.collider_vel;
|
floor_velocity = col.collider_vel;
|
||||||
|
if (p_stop_on_slope) {
|
||||||
|
// move and collide may stray the object a bit because of pre un-stucking,
|
||||||
|
// so only ensure that motion happens on floor direction in this case.
|
||||||
|
col.travel = p_floor_direction * p_floor_direction.dot(col.travel);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
apply = false; //snapped with floor direction, but did not snap to a floor, do not snap.
|
apply = false; //snapped with floor direction, but did not snap to a floor, do not snap.
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue