浏览代码

Fix 3D character snap on moving platforms

Applying the platform velocity when leaving the platform floor should be
done after snapping to keep things consistent, like it's done in 2D.
PouleyKetchoupp 4 年之前
父节点
当前提交
2084bb5eb9
共有 1 个文件被更改,包括 5 次插入5 次删除
  1. 5 5
      scene/3d/physics_body_3d.cpp

+ 5 - 5
scene/3d/physics_body_3d.cpp

@@ -1176,11 +1176,6 @@ bool CharacterBody3D::move_and_slide() {
 		}
 		}
 	}
 	}
 
 
-	if (!on_floor && !on_wall) {
-		// Add last platform velocity when just left a moving platform.
-		linear_velocity += current_floor_velocity;
-	}
-
 	if (was_on_floor && snap != Vector3()) {
 	if (was_on_floor && snap != Vector3()) {
 		// Apply snap.
 		// Apply snap.
 		Transform3D gt = get_global_transform();
 		Transform3D gt = get_global_transform();
@@ -1213,6 +1208,11 @@ bool CharacterBody3D::move_and_slide() {
 		}
 		}
 	}
 	}
 
 
+	if (!on_floor && !on_wall) {
+		// Add last platform velocity when just left a moving platform.
+		linear_velocity += current_floor_velocity;
+	}
+
 	return motion_results.size() > 0;
 	return motion_results.size() > 0;
 }
 }