Re-parenting object resets animator

Starting on or about 5.2.2, re-parenting an object with an active animator appears to reset the animator (params are cleared, state resets to default state, etc). Its almost as if the underlying code was changed to perform a deactivate/re-activate.

Is this intended behavior and is there a way to prevent this?

I’m surprised nobody else has ran into this. Is re-parenting an object while animating that rare? We definitely confirmed that a Unity version upgrade was what broke our system. One version worked fine, the newer one was blasting away all machine state info. I noted that there was some animation “reset” bugs that were fixed according to the release notes. Perohaps an unintended side effect?

So people either 1) don’t do this often, 2) the update broke/changed the mechanim behavior, 3) our code never should have worked to begin and was unintended behavior.

Can anyone else at least confirm they’ve experienced this issue?

It seems pretty fundamental to be able to re-parent an object.

Re-parenting object while animating can have many side effect.

  1. You can break your animation, animation curve are binded to object property with the transfrom path, changing the transfrom hierarchy can change your transform path and thus break the bindings.
  2. Re-parenting object is a costly operation that can have a huge impact on your performance depending if your are inserting at the top of the hierarchy or at the end.

I know that for 5.3 we did rewrite the transform component and it did affect how parenting work which could have break your project.
If you can please log a bug with you’re project and we will investigate.

1 Like

Thanks for this post. I realize this is a bit old but while working in Unity 2020.3 on a simple project I couldn’t figure out why my exit’s animation states were resetting. Come to find out that this is still a thing in 2020.3 I refactored the code to simply set its position and rotation of my exit to the transforms position and rotation and works like a charm. Thanks again.

Soooo, is there a workaround for that except not using parenting?
2021.3.8f1
UPD:
Animator.keepAnimatorControllerStateOnDisable = true;

1 Like

oh my god.. this saved my mental health. THANK YOU SO MUCH.

my issue was: -->Animator integer value resets - stuck. (On a scenario : Disabling - Enabling and reparenting of the animator object)