Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

One large animatorcontroller, or swap between smaller ones?

Discussion in 'Animation' started by protopop, Feb 19, 2019.

  1. protopop

    protopop

    Joined:
    May 19, 2009
    Posts:
    1,557
    I have an open world game with main characters and secondary NPCs

    The main characters have a complex animatorcontroller with many different states (sliding, jumping, etc)

    The secondary NPCs and enemies use a less complex animator controller.

    I would like to add emotion poses (happy, sad, angry, talking etc maybe 10 to 20) for all characters to use.

    What's the best option for performance and simplicity?

    1. Add all the mood animation states to both Main and Secondary animatorcontrollers. Just extending what i doing now adding more animations. But i feel like this may just be leading to bloated animatorcontrollers.

    2. Get rid of the simpler animatorcontroller used by NPCs and just have everyone use the single complex master controller.
    This would be really easy to manage and would allow every living humaoid to access all the same animations. But would it be bad for lesser NPCs who may not need all these animations use such a heavy animatorcontroller?

    3. Create a seperate "Mood" animator controller, and swap it in whenever a main or secondary character wnats to express a pose.
    This would mean managing the swap between the main controller to moods and then back when done. It sounds maneagable but is it too complicated for nothing?

    What do you think is best?

    sentri.jpg
     
    sonnyb likes this.
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,555
    Relevant Reddit thread. Specifically, my comment.

    TL;DR:
    • Swapping AnimatorControllers has a significant performance cost and should be avoided.
    • Having large AnimatorControllers is bad for development productivity.
    • AnimatorOverrideControllers are the official way you're supposed to swap out animations at runtime, but they have a few odd quirks and are still quite limited.
    • My Animancer plugin gives you much more freedom at runtime. It lets scripts play AnimationClips directly (without setting up a state in an AnimatorController beforehand) and even lets you play and blend between multiple AnimatorControllers (meaning you can make lots of smaller ones that are all much more manageable than one giant monstrosity). There's a link in my signature below.
    If you don't want to use my plugin for whatever reason, I'd recommend looking into the Playables API to make your own similar system (though that would take a lot more time and effort than the cost of my plugin).
     
    sonnyb and protopop like this.