Search Unity

Multiple States vs. AnimatorOverrideController for changing out animation clips

Discussion in 'Animation' started by Limnage, Feb 6, 2021.

  1. Limnage

    Limnage

    Joined:
    Sep 12, 2013
    Posts:
    41
    Often times in a game you'll have a single logical animation states with many possible animations in that state depending on the circumstances.

    One example is ability animations. When the character uses an ability, you want them to do the ability animation, but the actual animation will probably depend on the ability data.

    One way is to do it with one animation state for each ability, and transitioning based on animator hashes.

    Downsides:

    1) Too many states when number of abilities is large
    2) Hard to make shared ability animation transition logic (e.g. do something when any ability animation starts)

    Another way is to using AnimatorOverrideController, loading the AnimationClips for each ability, and swapping them out at run time for the correct animation for the ability being used.

    Downsides:

    1) Hard to make different animations for different characters. For example, if you want the Human animation for Whirlwind and the Orc animation for Whirlwind to look different, then this doesn't seem possible because you're loading the animation based on the name in code.


    What are the best practices in this scenario? Is there a way to do data-driven animations (use a different animation for different abilities) while still sharing state logic, and still having the possibility for different animations for different characters?
     
    Drenyn and F5Foxie like this.