summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorCamille Mohr-Daurat <pouleyKetchoup@gmail.com>2021-11-22 08:27:56 -0700
committerGitHub <noreply@github.com>2021-11-22 08:27:56 -0700
commit66ba19a435fb53ce53c1c0a355920cf8fb111e58 (patch)
tree0ebfb53d2f5502eb4c75caa4a18339b54456f10d /scene
parent76aa1d0a433441e9bd863e1f489e9905c545f630 (diff)
parentb738af86daad21511a338e28ae0319e638e73399 (diff)
Merge pull request #55202 from fabriceci/fix-wall-acceleration-in-3d
Fix wall acceleration in move and slide (3D)
Diffstat (limited to 'scene')
-rw-r--r--scene/3d/physics_body_3d.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp
index b731e0a2da..edaf76bc3e 100644
--- a/scene/3d/physics_body_3d.cpp
+++ b/scene/3d/physics_body_3d.cpp
@@ -1299,7 +1299,6 @@ void CharacterBody3D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
// in order to avoid blocking lateral motion along a wall.
if (motion_angle < .5 * Math_PI) {
apply_default_sliding = false;
-
if (p_was_on_floor && !vel_dir_facing_up) {
// Cancel the motion.
Transform3D gt = get_global_transform();
@@ -1307,14 +1306,18 @@ void CharacterBody3D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo
real_t cancel_dist_max = MIN(0.1, margin * 20);
if (travel_total <= margin + CMP_EPSILON) {
gt.origin -= result.travel;
+ result.travel = Vector3(); // Cancel for constant speed computation.
} else if (travel_total < cancel_dist_max) { // If the movement is large the body can be prevented from reaching the walls.
gt.origin -= result.travel.slide(up_direction);
// Keep remaining motion in sync with amount canceled.
motion = motion.slide(up_direction);
+ result.travel = Vector3();
+ } else {
+ // Travel is too high to be safely cancelled, we take it into account.
+ result.travel = result.travel.slide(up_direction);
+ motion = motion.normalized() * result.travel.length();
}
set_global_transform(gt);
- result.travel = Vector3(); // Cancel for constant speed computation.
-
// Determines if you are on the ground, and limits the possibility of climbing on the walls because of the approximations.
_snap_on_floor(true, false);
} else {