From 1fccf78dd2f850727a8cbf22bd0245a44e9f3d51 Mon Sep 17 00:00:00 2001 From: PouleyKetchoupp Date: Wed, 23 Dec 2020 20:04:22 -0700 Subject: [PATCH] Update body transforms on joint2D setup Body transforms from physics are used to setup the joint and they are only updated before the physics step by default. Without forcing the transform update, joints could use a previous position if the body's position was set after it was added to the scene. 3D physics is not affected by this issue. (cherry picked from commit 11bee25de4d07497d3bb8f3165937c879f0c9ef8) --- scene/2d/joints_2d.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scene/2d/joints_2d.cpp b/scene/2d/joints_2d.cpp index 3f0ea38ed48..9b8400b7226 100644 --- a/scene/2d/joints_2d.cpp +++ b/scene/2d/joints_2d.cpp @@ -90,6 +90,14 @@ void Joint2D::_update_joint(bool p_only_free) { warning = String(); update_configuration_warning(); + if (body_a) { + body_a->force_update_transform(); + } + + if (body_b) { + body_b->force_update_transform(); + } + joint = _configure_joint(body_a, body_b); ERR_FAIL_COND_MSG(!joint.is_valid(), "Failed to configure the joint.");