Reputation: 307
What's the optimal way of reusing animation, rigs and controllers in a complex setup with multiple characters in Unity 2022.3?
I've got a somewhat complex scenario:
One character that has 20 skins, and while skins share a lot of animation and rigging structure basics, there are differences between them:
1.1. Some (not all) skins have a Walk
loop clip that has the same name and serves the same purpose but have a different gait.
1.2. Some skins have appendages like a tail, wings, etc, that reflect in their rigging structure.
1.3. Some skins have extra actions/clips, like Fly
or Dive
.
The character is non-humanoid: it's actually two characters, one riding another. I've noticed that, by not sticking to humanoid, some features seem to be unavailable on Mechanim. Yet, separating the rig in two humanoids ain't practical at all for animating.
Each skins is currently exported with model/rig/anim to FBX from Blender.
Within Unity, skins will have constraints/behaviors inserted into the rig structure to make characters look at directions or procedurally animate tails, for instance.
I've created a controller with a state machine that has Blend States so the character will idle/walk/run/sprint (different clips) depending on its speed and I'd like to keep this.
Now I'm facing some hard to answer questions before moving ahead:
a) How to reuse an Animation Controller between several anim variations? Can I make something like a "prefab variation" to a Controller?
b) Is it ever possible to reuse the Anim Controller at all or will I have to setup an entire state machine for each character?
c) How to set up constraints and behaviors across all 20 some skins in I way so to keep ok maintenance?
Upvotes: 0
Views: 50
Reputation: 10860
If I understood correctly, AnimatorOverride
can do the trick for you.
https://docs.unity3d.com/Manual/AnimatorOverrideController.html
The only restriction is that you will have to set all the states for every override to ensure it works correctly (like instead of unique "wave with hand" or "make a warm-up" it can be a single state "CustomIdle" that will refer to different animations for every override).
We'd shared once such a controller for about one hundred characters, and this solution has proven itself to be a good one. There were only one basic controller with states like attack1
, attack2
, attack_special
, walk
, run
, idle
, death
, etc. And an override for each of the models. For similar (i.e. compatible) models some of the animations were reused without issues. At least from what I remember.
So, the basic animator was kind of complex, but all the changes there were automatically shared with all overrides. Our art team was able to create new overrides without any code at all because for them, it was simply a requirement: "To complete this character setup, make sure all the animation required are set."
Upvotes: 1