Search Unity

AnimatorOverrideController should act on the state names of an AnimatorController

Discussion in 'General Discussion' started by Shadoninja, May 20, 2018.

  1. Shadoninja

    Shadoninja

    Joined:
    Nov 12, 2013
    Posts:
    26
    I just spent hours figuring out how to implement an AnimatorOverrideController (AOC) programatically. My key misunderstanding was the way the AOC keeps track of the clips from the original RuntimeAnimatorController (RAC).

    When overriding clips from an object's original RAC, the AOC needs to override the RAC clips directly by name. I think this is a design flaw. The AOC should be overriding the RAC's clips by its parent Animator Controller's (AC's) state names. This allows a creator to use the editor-created AC as the source of truth, rather than whatever clips were originally applied it.

    I will try to help elaborate on what I just said through an example:

    Let's say you make an AC with one state in it, Idle. You rig up an AnimationClip to it titled PlayerIdle. Now let's say you want to make a second character that will also need its own idle animation. What you would do is create an AOC that uses the AC's RAC with the Idle state on it as a base. In order to programatically add the CharacterTwoIdle AnimationClip to it in C#, you need to apply the CharacterTwoIdle animation clip directly to the PlayerIdle AnimationClip on the AOC using a static string reference. This should not be the case. You should be applying the CharacterTwoIdle AnimationClip to the Idle state of the AC.

    Essentially what I want is an Animator Controller that serves as a template that I can interact with through code. If I have 5 different Game Objects with a similar animation flow, let me make a generic Animation Controller that I can coherently plug my animations into programatically.