Merge pull request #53239 from nekomatata/fix-animatable-body-initial-state

This commit is contained in:
Rémi Verschelde 2021-09-30 15:15:00 +02:00 committed by GitHub
commit 5d6a98f04e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View file

@ -288,6 +288,12 @@ void AnimatableBody2D::_notification(int p_what) {
switch (p_what) { switch (p_what) {
case NOTIFICATION_ENTER_TREE: { case NOTIFICATION_ENTER_TREE: {
last_valid_transform = get_global_transform(); last_valid_transform = get_global_transform();
_update_kinematic_motion();
} break;
case NOTIFICATION_EXIT_TREE: {
set_only_update_transform_changes(false);
set_notify_local_transform(false);
} break; } break;
case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: { case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
@ -313,7 +319,6 @@ void AnimatableBody2D::_bind_methods() {
AnimatableBody2D::AnimatableBody2D() : AnimatableBody2D::AnimatableBody2D() :
StaticBody2D(PhysicsServer2D::BODY_MODE_KINEMATIC) { StaticBody2D(PhysicsServer2D::BODY_MODE_KINEMATIC) {
_update_kinematic_motion();
} }
void RigidDynamicBody2D::_body_enter_tree(ObjectID p_id) { void RigidDynamicBody2D::_body_enter_tree(ObjectID p_id) {

View file

@ -340,6 +340,12 @@ void AnimatableBody3D::_notification(int p_what) {
switch (p_what) { switch (p_what) {
case NOTIFICATION_ENTER_TREE: { case NOTIFICATION_ENTER_TREE: {
last_valid_transform = get_global_transform(); last_valid_transform = get_global_transform();
_update_kinematic_motion();
} break;
case NOTIFICATION_EXIT_TREE: {
set_only_update_transform_changes(false);
set_notify_local_transform(false);
} break; } break;
case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: { case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
@ -367,8 +373,6 @@ void AnimatableBody3D::_bind_methods() {
AnimatableBody3D::AnimatableBody3D() : AnimatableBody3D::AnimatableBody3D() :
StaticBody3D(PhysicsServer3D::BODY_MODE_KINEMATIC) { StaticBody3D(PhysicsServer3D::BODY_MODE_KINEMATIC) {
PhysicsServer3D::get_singleton()->body_set_state_sync_callback(get_rid(), this, _body_state_changed_callback); PhysicsServer3D::get_singleton()->body_set_state_sync_callback(get_rid(), this, _body_state_changed_callback);
_update_kinematic_motion();
} }
void RigidDynamicBody3D::_body_enter_tree(ObjectID p_id) { void RigidDynamicBody3D::_body_enter_tree(ObjectID p_id) {