diff options
author | PouleyKetchoupp <pouleyketchoup@gmail.com> | 2021-08-09 12:14:24 -0700 |
---|---|---|
committer | PouleyKetchoupp <pouleyketchoup@gmail.com> | 2021-08-09 12:30:17 -0700 |
commit | 5650c83e4b7f669066685a9f5526d7ec56e9b43d (patch) | |
tree | 401c9269dab589614f85536eb083d53a86ac5cb5 /scene/3d/physics_body_3d.cpp | |
parent | 0cee8831b25377567bff8f46f7eaad8cb203dbf8 (diff) | |
download | redot-engine-5650c83e4b7f669066685a9f5526d7ec56e9b43d.tar.gz |
Fix applied rotation from moving platforms in move_and_slide
When synchronizing CharacterBody motion with moving the platform using
direct body state, only the linear velocity was taken into account.
This change exposes velocity at local point in direct body state and
uses it in move_and_slide to get the proper velocity that includes
rotations.
Diffstat (limited to 'scene/3d/physics_body_3d.cpp')
-rw-r--r-- | scene/3d/physics_body_3d.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp index 100e3563a3..38104a8365 100644 --- a/scene/3d/physics_body_3d.cpp +++ b/scene/3d/physics_body_3d.cpp @@ -1101,7 +1101,9 @@ void CharacterBody3D::move_and_slide() { //this approach makes sure there is less delay between the actual body velocity and the one we saved PhysicsDirectBodyState3D *bs = PhysicsServer3D::get_singleton()->body_get_direct_state(on_floor_body); if (bs) { - current_floor_velocity = bs->get_linear_velocity(); + Transform3D gt = get_global_transform(); + Vector3 local_position = gt.origin - bs->get_transform().origin; + current_floor_velocity = bs->get_velocity_at_local_position(local_position); } } |