Thousands of Animations

Hi, I’m working on an RPG. This means a lot of animations. Animations ranging from a stand, walk, run, attack (probably more than 1 attack animation), block animation PER Weapon! As well as animations for jumping over obstacles, emotes, etc.

My confusion is the animation state system. It’s a great system for games like xbox games that have limited number of character animations, but how can I handle thousands of animations? I need to be able to just call…

character.performAnimation(id).

That would be amazing cuz I could assign any animation whenever it is needed, rather than using the state system for every single ID. Is there a way to even do this? if so will it lose the transitions?

All help, tips, recommendations are appreciated!

The best recommendation I think is to collaborate with someone who knows about setting up animations systems. Or alternatively spend a considerable amount of time learning through iteration, and trial & error how to set up a system that works best for your application.
This system is do-able but requires some pre-planning for the characters, enemies and animation rigs, time dedicated strictly to working on the animation system and documentation for motion flow charts - rigs and state machines that can be used for multiple characters/enemies - accessories and extra bones and pieces.
Some animations will undoubtedly be unique to certain characters/enemies or groups/factions.

May consider looking into some of the popular moba and mmo games also. I’m sure with the number of characters/enemies they use - the animation system setup is probably similar to your end goal. They most likely use a different engine but the animation logic is still the same.

Sounds like an interesting project!

1 Like

You don’t necessarily need thousands of separate animation clips. From the waist down, is walking with a sword any different from walking with a mace, or an axe, or a club? Mecanim does a great job with animation layers and blending. Both are techniques for getting lots of mileage and variation out of a much, much smaller number of animation clips. The management of these layers and blends is usually handled by a higher-level animation logic component, such as ooti’s Motion Controller.

@theANMATOR2b has a great recommendation – collaborate with someone who has experience with layers and blend trees, or give yourself a head start by using something like Motion Controller as a template.

1 Like

Well actually walking with different weapons would be a bit different. Also I plan to have 3/4 unique abilities that come along with each weapon with unique animations, along with tons of non-combat animations relating to cutting trees, gathering things, cutting things, etc. There really will be a lot of animations.

Am I restricted to having to manually enter every animation clip to have essentially a flower with 1000 petals extending from the center state in the animation window?

My point is just that games very often re-use animations on different body parts. As a more obvious example, a character can smile (facial bone animation) regardless of whether he’s wielding a sword, a bow, a staff, or a bazooka, or whether he’s standing, sneaking, running, or swimming. You don’t need to tie the smile to the swim animation, and tie another smile to the run animation, etc.

I don’t know if this will help you or not, but: Unity Asset Store - The Best Assets for Game Making

TonyLi is absolutely correct and one of the more experienced people around here regarding animation systems (known only from reading his posts).

To add a little helpful forward direction - it mostly boils down to the number of characters/enemies that can use the same base animation rig that mecanim recognizes. The number of animations can be drastically reduced by this pre-planning of characters and animation rigs. Tony’s example of using the facial bone setup can be applied to numerous characters/enemies as long as the rig is the same. Same animation for multiple characters no need to have 10 smile animations for 10 characters. And this animation can be used regardless of what the rest of the body is doing.

To your point about - walking with different weapons would be a little different - can be applied (not a coder) via code I assume by “if” statement ?? Guessing here but (If) the character was carrying a heavy two handed axe apply blend animation of canting to one side or compensating on one side because the axe is heavy.

This canted animation could be used for all your characters as long as they are bipedal. Your animation flower with 1000 pedals is drastically reduced for bipedal characters anyway.

Ok. So I know I can make the visual animation window work… I’m just not thrilled.
The link hopeful linked seems a bit closer to what I’m looking for.
In that asset from the asset store… it looks like the script is actually telling mechanim what animation to play.

What I would find very very useful is how they did that by script. I’ve looked through the documentation and have not found how to tell mechanim to perform an animation based on the animation asset… That is what I really need.

Edit:
Did some searching. Found a unity dev post this post: http://forum.unity3d.com/threads/mecanim-runtime-animation.161038/#post-1434143

Looks like I might be able to override it. Then I could create a very very basic mecanim system with Idle, walk, attack (1,2,3,4,5), block, perform (meaning like any on deman animation), and a while walking (for eating/hand movement while walking). Then I can simply swap out the animation clips for each piece so when a user changes his weapon, it updates all of the animation types listed (besides perform and while walking).

I could also change the perform animation to any clip at runtime such as dance, bow, other miscellanious on demand animations.

Here’s the code from the post

RuntimeAnimatorController myController = animator.runtimeAnimatorController;
AnimatorOverrideController myOverrideController = new AnimatorOverrideController();
myOverrideController.runtimeAnimatorController = myController;

myOverrideController["run"] = myRunFasterClip;

// Put this line at the end because when you assign a controller on an Animator, unity rebind all the animated properties
animator.runtimeAnimatorController = myOverrideController;

Haven’t tried it yet… but if it works it looks like I can have any animation on demand as well as keep the smooth transitions of mecanim & layers etc.

1 Like

Let me know how it goes. I’ve not tried it yet, having been busy with other things, but as I was browsing around it looked like a possible solution for a massively detailed animation project, or at least something that might get you most of the way there.

I’ll try a rough test of the overall system tonight. I’ll post my results :slight_smile:

1 Like

You have some API function that allow you to trigger manually your animation from script.

If you prefer to to have absolute control by script rather than using the UI to create your transition, you can simply drag and drop all your clip in a controller, and then trigger your animation manually with Animator.Play or Animator.CrossFade.

But like @theANMATOR2b and @TonyLi are suggesting, if you plan your controller carefully you will be able to reuse a lot of animation clip for all you different character saving you a lot of time and resources.

I gather the plugin I mentioned before - Mecanim Control - can’t yet do animation layers. Are layers something we can script, or is that functionality currently reserved to just the mecanim state machine?

It seems that this plugin does not use the latest capabilities of the Mecanim API.
I’ve given this plugin a try, but, now in most case it’s not necessary.

Animation Layer can only be added in the editor either with the UI or with the scripting API