Fix move_and_slide wall slide acceleration (3D)

When travel is high enough, keep the global position resulting from the
move_and_collide call, and set the motion to the remainder from the
move_and_collide call. This ensures travel is taken into account once,
rather than twice.

(cherry picked from commit 80c600d86b)
This commit is contained in:
Ricardo Buring 2024-04-19 19:40:01 +02:00 committed by Rémi Verschelde
parent 8638b5ff32
commit 32262931ca
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 1 additions and 1 deletions

View File

@ -1362,7 +1362,7 @@ void CharacterBody3D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
} else { } else {
// Travel is too high to be safely canceled, we take it into account. // Travel is too high to be safely canceled, we take it into account.
result.travel = result.travel.slide(up_direction); result.travel = result.travel.slide(up_direction);
motion = motion.normalized() * result.travel.length(); motion = result.remainder;
} }
set_global_transform(gt); set_global_transform(gt);
// Determines if you are on the ground, and limits the possibility of climbing on the walls because of the approximations. // Determines if you are on the ground, and limits the possibility of climbing on the walls because of the approximations.