5.2 Animator behavior changed

The animation behavior in 5.2 has change significantly compared with previous versions. From at least version 4.3 to 5.1, if you created an animation for a Gameobject, all the properties that were not touched by the animation were set to their original value when starting the animation, for example: suppose you have 2 animations, animation A makes your 2D character to walk, while animation B makes your character fade away to invisibility. If you play A, you’ll see the character walking, if then you play B, the character will be animated to its original position and rotation while fading away to invisibility, a very nice effect. If latter on, you needed to make the character appear walking again you just had to play A again, since every property not included in A was reset to its original value you didn’t have to worry about the character being invisible, it just appeared walking again like magic. But in 5.2 if you play animation A the original values are no reset, so if you play it once B has played, you won’t see your character walking because is remains invisible, as the original values are not restored.

Another thing that changed is that when you disabled the animator, the parameters’ values remained unchanged, you could relay on that to pause your game without having to set Time.timeScale to 0, so you could still use animations for your UI elements. In 5.2 when you disable the animator, all boolean parameters are set to false. I don’t have numeric parameters on my animator controllers, so I can’t tell if this also happens with numeric parameters, but its a fact that boolean parameters are reset to false, so when you re-enable the animator your characters just freeze until an event sets the parameters again.

I don’t know if this is a bug or a feature, but it is certainly annoying. I don’t know if there is a work around or if I better downgrade to 5.1 until this problem is fixed.

After one day of trail and error, I discovered that all my animation problems were caused by: anim.enabed = false, so instead of disabling the animation I’m now setting speed to 0, this magically solved all my problems. However, there’s a notorious performance loss between anim.enabled = false / true and anim.speed = 0 / 1 in Unity 5.2. In Unity 5.1.3 performance seems to be the same regardless of which method you choose.