summaryrefslogtreecommitdiff
path: root/scene/2d/physics_body_2d.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-08-09 23:20:44 +0200
committerGitHub <noreply@github.com>2021-08-09 23:20:44 +0200
commit2de5d2361ac39e61c610d6fc0f161a1237ae2815 (patch)
tree393cad3673fe40a5291c7c5e458e5935b977d8a5 /scene/2d/physics_body_2d.cpp
parent7bcfc66fb4253fb121008809e4e81c5b704776b7 (diff)
parent5650c83e4b7f669066685a9f5526d7ec56e9b43d (diff)
Merge pull request #51446 from nekomatata/fix-moving-platform-rotation
Fix applied rotation from moving platforms in move_and_slide
Diffstat (limited to 'scene/2d/physics_body_2d.cpp')
-rw-r--r--scene/2d/physics_body_2d.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index a382fb2f1e..00eeb60192 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -1062,7 +1062,9 @@ void CharacterBody2D::move_and_slide() {
//this approach makes sure there is less delay between the actual body velocity and the one we saved
PhysicsDirectBodyState2D *bs = PhysicsServer2D::get_singleton()->body_get_direct_state(on_floor_body);
if (bs) {
- current_floor_velocity = bs->get_linear_velocity();
+ Transform2D gt = get_global_transform();
+ Vector2 local_position = gt.elements[2] - bs->get_transform().elements[2];
+ current_floor_velocity = bs->get_velocity_at_local_position(local_position);
}
}