At times it is very convenient to separate animations to multiple assets. A common scenario is to have rigged models separated from animations or different animation types separated from each other (combat from movement, movement from actions, actions from cut scenes, and so on). This recipe shows how to do it for both Humanoid
and Generic
rigs.
Before we start, you should prepare and import at least two assets containing animations. If you are using a Generic
rig, make sure to have the same rig in both assets. You can also use the provided example Unity project and go to the Chapter 01 Working with animations\Recipe 06 Using animations from multiple assets
. There is a scene called Example.unity
file there. In the scene Hierarchy
you can find a Character
game object. It has an attached Animator Controller
in which you can find two animations: Idle
and Wave
. In the Rigs
directory, you will find the Character.fbx
asset containing only a rigged character along with the Idle.fbx
and Wave.fbx
assets containing the corresponding animations.
To use animations from multiple assets, you need to follow these steps:
- Import the files to Unity.
- If you are using the Generic rig, you have to set the
Avatar Definition
toCreate From This Model
on your character (or reference character if you plan to have multiple characters with the same rig). For each imported animation asset, set theAvatar Definition
toCopy From Other Avatar
and choose the avatar of your character or reference character. To do so, you need to unfold the character asset, find the avatar, and drag and drop it to theSource
field in theInspector
tab.
- If you are using a
Humanoid
rig, you don't have to copy theAvatar Definition
(you still can if your rigs are exactly the same; that way you will have fewer avatars in your project, making it easier to find the ones you need). - Create or open an
Animator Controller
. - Assign animations from different files and build transitions between them.
- Run the game to see the animations work.
All Generic
rigs can use animations from multiple assets that share the same Avatar Definition
. To share the same Avatar Definition
, Generic
rigs have to have exactly the same rigs (the same hierarchy, the same bone names and transforms). All Humanoid
rigs can use animations from multiple assets that are also set to Humanoid
. Additionally, they don't need to have the same rigs because Unity automatically retargets all humanoid animations.