- Home /
AnimatorOverrideController runtime sprite problem
Hey guys!
I stucked with the following problem: In my game I use AnimatorOverrideController in my script in order to override IDLE, MOVE and ACTION animations for different types of generic character. And it happens that some character sprites don't return back after animation (e.g. face emotion changes and doesn't return to the one before an animation, or hand changes direction and stays in that position afterwards).
Any help would be appreciated!
Code pattern is as follows:
protected override void Awake()
{
CacheAnimator = GetComponent<Animator>();
CacheAnimatorController = new AnimatorOverrideController(CacheAnimator.runtimeAnimatorController);
CacheAnimator.runtimeAnimatorController = CacheAnimatorController;
// Setting idle state for a character
CacheAnimatorController[IDLE] = idleAnimation;
}
public void PlayMove(AnimationClip moveAnimation)
{
CacheAnimatorController[MOVE] = moveAnimation;
CacheAnimator.SetBool(ANIM_KEY_MOVE, true);
}
public void ChangeActionClip(AnimationClip clip)
{
CacheAnimatorController[ACTION] = clip;
CacheAnimator.SetBool(ANIM_KEY_DO_ACTION, true);
}
PS. May be guys at @Mecanim-Dev could also help ..
Answer by unity_oaz2St4maRukXA · Sep 16, 2020 at 11:46 AM
Yes, I'm pretty sure.
I forgot to mention that if I create AnimatorOverrideController as an asset in Unity Editor and override IDLE, MOVE and ACTION animations there - everything works fine. The problem is that I will have to change many things in my project in order to move from script-defined AnimatorOverrideController to the asset one.
Your answer
Follow this Question
Related Questions
Unity Sprite Editor Error 0 Answers
Bug with AnimatorOverrideController with Sprites 0 Answers
How do I animate a 2D sprite? 1 Answer
Sprite animation is not updating (possible bug) 1 Answer
Changing one keyframe in my animation changes all of them 2 Answers