Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Create Animation Controller Asset Template?

Discussion in 'Animation' started by Gordon_G, Nov 4, 2021.

  1. Gordon_G


    Jun 4, 2013
    I've got a project with hundreds of 2D frame-by-frame animated characters, each with their own Animation Clips for Idle, Focused, Walk Up, Down, Right and Left.

    Idle and Focused are set up as animation States, and the motion direction animations are grouped in a Blend Tree.

    The process of setting up the Animator Controller asset with the States and a Blend Tree for the motion of each character is going to be time consuming with that many to deal with.

    There doesn't seem to be a way to create a copy of an existing controller and simply replace the Animation Clips - for a Blend Tree it seems I will have to recreate the tree at least (no way to, in essence, set up an Animation Controller Template that keeps the same Blend Tree values and just replace the Animation Clips referenced).

    1. Am I missing something? - It is possible to replace the Animation Clips in a Blend Tree without having to rebuild the tree?

    The other option is to do it programmatically and I am trying to scope out the issues before hacking and slashing my way though the API...

    In the API documentation I see that I can access a BlendTree and potentially replace it's children:

    2. One question is, where to attempt this, at runtime or in an editor script?

    If I do it in an editor script, I gather I will need to make a unique copy of the "template" Animator Controller for each character.

    3. is it possible to copy an Animator Controller through the AssetDatabase API (I'm guessing yes)

    If I do it at runtime, I could set up a prefab with a "template" Animator Controller asset referenced from the prefab's Animator component, but then my question is:

    4. Does a spwaned copy of the prefab then reference a unique instance of the "template" Animator Controller in memory, or will all spawned instances reference the same Animator Controller asset and any programmatic change I make to the Animator Controller asset will be reflected in all instances of my prefab? (similar to how scriptableobjects behave)

    I hope all that makes sense and thanks in advance for your ideas!

    [these questions seem related this recent thread, but I don't see answers there:]
    Last edited: Nov 4, 2021