- Home /
Unity 5.6 Animator.Rebind doesn't work - Animator doesn't reset on disable & re-enable gameobject
Hi, just migrated to Unity 5.6 today.
On Unity 5.5.2, when gameobject with animator is disabled then re-enabled, i can expect the animation is reset. And I am taking that advantages in my game so much. In 5.6 the behavior doesn't like that and I tried to manually call the Animator.Rebind(), it doesn't do anything.
Anyone has same problem ? Or anyone has already had solution ? Thank you.
Same problem here! When version 5.6.0p1 will be released with the fix? All our animators are broken since the update to Unity 5.6.0f3
Have same bug in the Unity 2017.3.0f3. Here is a workaround: https://forum.unity.com/threads/losing-animator-state.307667/#post-3598984
Answer by SaintGrey · Apr 25, 2017 at 05:12 AM
Try this:
Animator.enable = true;
Animator.Play("your entry state", 0, 0f);
Answer by Jix · Apr 11, 2017 at 08:39 PM
The solution that worked for me is when an object gets disabled I do something like this
OnDisable()
{
Destroy(myAnimator);
}
And in OnEnable()
OnEnable()
{
if(myAnimator == null)
{
myAnimator = gameObject.AddComponent<Animator>();
myAnimator.runtimeAnimatorController = myPrefab.myAnimator.runtimeAnimatorController;
//Don't forget to set applyRootMotion and the avatar if needed
}
}
I don't understand how and where you create, set and store the prefab for an animator controller and all the stuff in it and to do with it, such as assigning the actual animation controller you've created in Unity's animator to the animation controller component on the object, such that you can assign that to the animator component that you've just created in code when the object is reactivated again?
I mean, I get the first part where you add an animator component to an object you've just activated if one doesn't exist already, but anything after that is a mystery to me.
Totally lost with:
myAnimator.runtimeAnimatorController = myPrefab.myAnimator.runtimeAnimatorController;
Your answer
Follow this Question
Related Questions
What's the best practice for setting up different character animations for different weapons? 0 Answers
IK Targets are not working 1 Answer
Animator problem in Create with Code. in Unit 3 1 Answer
Moving an animated object's animator instead of the object? 0 Answers
OnCollision2D stopped working 1 Answer