mirror of https://github.com/godotengine/godot
Merge pull request #99397 from yosoyfreeman/master
Allow `apply_floor_snap` to preserve the horizontal position regardless of `stop_on_slopes`
This commit is contained in:
commit
b88fd31687
|
|
@ -352,14 +352,14 @@ void CharacterBody2D::_apply_floor_snap(bool p_wall_as_floor) {
|
|||
floor_normal = result.collision_normal;
|
||||
_set_platform_data(result);
|
||||
|
||||
if (floor_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.
|
||||
if (result.travel.length() > margin) {
|
||||
result.travel = up_direction * up_direction.dot(result.travel);
|
||||
} else {
|
||||
result.travel = Vector2();
|
||||
}
|
||||
// Ensure that we only move the body along the up axis, because
|
||||
// move_and_collide may stray the object a bit when getting it unstuck.
|
||||
// Canceling this motion should not affect move_and_slide, as previous
|
||||
// calls to move_and_collide already took care of freeing the body.
|
||||
if (result.travel.length() > margin) {
|
||||
result.travel = up_direction * up_direction.dot(result.travel);
|
||||
} else {
|
||||
result.travel = Vector2();
|
||||
}
|
||||
|
||||
parameters.from.columns[2] += result.travel;
|
||||
|
|
|
|||
|
|
@ -469,14 +469,14 @@ void CharacterBody3D::apply_floor_snap() {
|
|||
_set_collision_direction(result, result_state, CollisionState(true, false, false));
|
||||
|
||||
if (result_state.floor) {
|
||||
if (floor_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.
|
||||
if (result.travel.length() > margin) {
|
||||
result.travel = up_direction * up_direction.dot(result.travel);
|
||||
} else {
|
||||
result.travel = Vector3();
|
||||
}
|
||||
// Ensure that we only move the body along the up axis, because
|
||||
// move_and_collide may stray the object a bit when getting it unstuck.
|
||||
// Canceling this motion should not affect move_and_slide, as previous
|
||||
// calls to move_and_collide already took care of freeing the body.
|
||||
if (result.travel.length() > margin) {
|
||||
result.travel = up_direction * up_direction.dot(result.travel);
|
||||
} else {
|
||||
result.travel = Vector3();
|
||||
}
|
||||
|
||||
parameters.from.origin += result.travel;
|
||||
|
|
|
|||
Loading…
Reference in New Issue