Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AnimatableBody3D not being movable in editor #72473

Merged

Conversation

aXu-AP
Copy link
Contributor

@aXu-AP aXu-AP commented Jan 31, 2023

Fixes #72416

This bug was introduced in #67847, which enables transform notifications in editor for collision objects, but AnimatableBody3D has logic in place which reverts the position. The proposed solution is to disable AnimatableBody3D's handling of notifications when running in editor.

Here's the relevant snippets that causes the problem in the first place:

if (Engine::get_singleton()->is_editor_hint()) {
set_notify_local_transform(true); // Used for warnings and only in editor.
}

case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
// Used by sync to physics, send the new transform to the physics...
Transform3D new_transform = get_global_transform();
PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_TRANSFORM, new_transform);
// ... but then revert changes.
set_notify_local_transform(false);
set_global_transform(last_valid_transform);
set_notify_local_transform(true);
_on_transform_changed();
} break;

@aXu-AP aXu-AP requested a review from a team as a code owner January 31, 2023 21:47
@akien-mga akien-mga requested review from rburing and a team January 31, 2023 21:53
@akien-mga akien-mga added this to the 4.0 milestone Jan 31, 2023
Copy link
Member

@rburing rburing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this oversight!

@aXu-AP
Copy link
Contributor Author

aXu-AP commented Jan 31, 2023

I was trying to fix entirely different bug earlier today which touches the same bits of code (I presume, haven't yet succeeded), so I could connect the dots once I saw this issue 😅

@akien-mga akien-mga merged commit a350b42 into godotengine:master Feb 1, 2023
@akien-mga
Copy link
Member

Thanks!

@aXu-AP aXu-AP deleted the animatablebody3d-editor-move-fix branch February 1, 2023 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't move AnimatableBody3D in the editor
3 participants