GameObject Transform values incorrect when disabled mid-animation


I have a GameObject with an Animator and Animation component. I made a simple MechAnim state machine with an idle (which does nothing) and one animation that tweens the local scale X value to make the object shrink and then expand (non-looping.) In the app, the object can get a SetActive(false) called on it at any point, and when this happens in the middle of the animation, the object’s local scale stays at whatever it was when the object was disabled when it is re-enabled later. So, if the object’s scale was [0.5, 1, 1] when it was set as inactive, when I set it active again, the object’s scale is stuck at [0.5, 1, 1] instead of returning to [1, 1, 1].

I’ve tried using Animator.Rewind() on the GameObject both in OnDisable() and OnEnable(). I’ve also tried recording the original scale values OnAwake() and then forcibly resetting the object’s local scale values in the first LateUpdate() after the object is set active again. None of these solutions work. The object goes right back to the [0.5, 1, 1] state even after I try to reset all animations and restore the transform values.

I could use some help figuring out how to smoothly handle interrupting animations that modify the GameObject’s transform values when I call SetActive() on the GameObject.

Good day.

I dont know the solution for the animation. But why dont just destroy the object and instantiate it again, instead of deactivating it?