Updating RunTimeAnimatorController at runtime changes the Transform of GameObject Incorrectly.

RuntimeAnimatorController newAnimController = Resources.Load(“AnimControllers/WalkAnimatorController”) as RuntimeAnimatorController;

 void changeAnimatorController()
{
       this.gameObject.GetComponent<Animator>().runtimeAnimatorController = newAnimController  ;
}

Now calling this function is working differently when called in the following two different ways:
1.If I call the function ‘changeAnimatorController’ directly from script, my Animator controller is getting updated to the new one, but gameObject’s position is getting changed to the gameObject’s original position present before the game play starts, and getting updated to the correct position in next frame.
2.If I call the function ‘changeAnimatorController’ from an event of animation clip present in current animator controller (which I am going to replace), gameObject’s position is getting changed to the gameObject’s original position present before the game play starts, and never getting updated to the correct value in any frame.

In the above two cases, after changing RunTimeAnimatorController of gameObject, rotation of gameObject is getting changed to gameObject’s original rotation present before game play starts.
Any idea why it’s happening this way? Why calling the function ‘changeAnimatorController’ from different places works differently?

I too have the same problem. It’s really needed and no where in unity docs it’s mentioned that transforms get changed after changing animator controller. Please let us know the correct procedure to change animator controller.
Please reply @UnityTechnologies, @RomainFailliot @Mecanim-Dev.

Thanks for reaching us. We don’t seem to know this bug yet.
I think the best would be to file a bug using the bug reporter directly from the Unity editor, so we (you and us) could track it.

Thanks :slight_smile: @RomainFalliot . I filed a bug asyou said , and got reply. It’s a bug in Unity previous versions, but not in 2017.x. Everything is working fine in Unity 2017.x.

Do you think you could use one of the 2017.x releases for your project?
5.6 is starting to be veeeeery old :wink: