Hello,
I’ve been trying to switch to the Mecanim animation system and I ran into a problem, to which I can’t find a solution.
Let’s say, I have 40 objects with animations. They all have different skeletons and animation lengths, but all objects have animations with the same names (e.g. “idle” and “action”). Is there a way to have a single Animator Controller for all of the objects (or maybe something similar)? Or do I have to create a controller for each object separately?
With legacy animations you could have a script, from which you run “idle” or “action” and it would work for all objects (no matter what skeletons or animation lengths they have). I’d like something similar and reusable for generic Mecanim animations.
Thanks in advance!
4 Answers
4
At the very least, you can use AnimatorOverrideController, but you will still have to fill in the variables:
You can, with Unity Pro, where you can check Sync on state machine layers to have lots of layers with the exact same state machine but with different animation clips, and then you set weight to 0 on the base layer and set the layer that corresponds to the character to weight 1.
Other than that I just know that you can duplicate an Animator Controller, but that’s not quite what you would want.
Hey, I’ve made an asset that can duplicate an animator controller and replace animation clips by new ones at the same time. Perfect if you have multiple character using the same kind of animator structure.
It can also detect changes in durations. Just check it out. I think it could help people with that kind of problem.
Here’s an video where I have multiple characters with the same controller structure: Example
And another one where I show how curves and events are also kept during transfer: Presentation
Thanks guys
I am trying to create a script that auto repopulates an Animation Override Controller - but I can’t seem to “write” to the animationClips property… it just resets.
Help 
wow... never read that before... Thanks for sharing !!! Beware of the "Copy current state machine" option. I am pretty sure that the copied state machine could be modified by it. And I recommend you to enter "al mano" all parameter first and then past the state machine in the new controller. Otherwise, some of them are not copied and several transition could be lost while pasting.
– thor_tillasHi Volcanic-Penguin, thanks a lot for your reply! I've tried it out and this feature seems very useful. On the other hand, it still means that I have to manually create 40 layers and drag the animation clips into each of them, right? This is much better than having 40 controllers, but still a bit sluggish in comparison to legacy animations (where you have to do nothing else, just call an animation from the script by name and you can use it on any object that has this animation; only one line of code, basically).
– DominoOneHmm yeah I think so, unless you write some clever editor script or something but that's out of my league. I think this might be something the Unity team is improving for future versions.
– Volcanic-PenguinI think editor script will not help much as the Mechanim API is not provided, at least for now... But yes, Unity team is working on that and I really hope we will able to modify controller and states pretty soon for my own sanity ^^
– thor_tillas