- Home /
Animator Override Controller changed at runtime doesn't always play the animations correctly
EDIT : The issue was not linked to Animator Override Controller but instead on the culling of the character models.
I have a character that is animated with one controller and that uses AnimatorOverrideController to change the animation by script during runtime. The problem is that sometime when a new AnimationClip is set in the AnimatorOverrideController, the animation is shown as playing in the Animator window but it stays at the frame it was before I changed the animation clip. If I pause the game and resume, it seems the Animator realizes it is not playing properly and is fixed.
Here's how I create my AnimatorOverrideController :
myAnimatorOverrideController = new AnimatorOverrideController(myAnimator);
myAnimator.runtimeAnimatorController = myAnimatorOverrideController ;
Here's how I change the animation clip and play my animations :
myAnimatorOverrideController[AnimationClipToOverride] = myNewOverrideAnimationClip;
myAnimator.Play(OVERRIDE_ANIMATION_STATE_NAME);
AnimationClipToOverride is a referenceto the default animation clip in myAnimator. OVERRIDE_ANIMATION_STATE_NAME is the name of the state in myAnimator where AnimationClipToOverride is in.
I have tried using Rebind and Update after updating my override clip but it doesn't fix the issue. I thought it could be caused by the animations not being loaded since they were not referenced by the animator, but I tried referencing them to see if it would fix the issue but it doesn't. In all cases, pausing the editor or adding a breakpoint always make the animations play properly.
I am not able to reproduce this using simple animations. It seems to only happen in a more complex environment using Avatars. The animator window shows the animation as playing so it might have to do with the animator not playing correctly on the avatar. Since it fixes itself when I pause, there might be a function called on Animator Pause which fixes it.
Answer by Sprawl · Jan 11, 2018 at 04:11 PM
Sorry for the late reply. It turns out the issue was actually in the Import Settings and not the Animator override controllers. It seems they were changed at the same time that we introduced the Animator Override Controllers. The problem was that the models didn't have the right culling method. Setting them to "Always Update" fixes my issue.
Hello! Can you tell me Where I can set them to "Always Update"? Thank you !