AnyPortrait > Manual > Using Mecanim

Using Mecanim


1.0.4

When creating games, many game producers use state machines to create animations.
In Unity, the Mecanim is responsible for the development process.
Unlike the traditional control of animation in a script, animation switching works as a state machine.
From version 1.0.4, AnyPortrait also supports animation control with Unity Mecanim.
The Mecanim system using Animator components is basically the best for Unity's Humanoid 3D model.
Therefore, AnyPortrait is not compatible with all features of Mecanim, so you should refer to this point.




First, create animations in AnyPortrait.
You can make it the same as the existing method.




Check "Is Mecanim Animation" in the Bake dialog box.
Because AnyPortrait converts animations into Animation Clips and saves them, you need to Set the Path where those assets will be stored.




Saving in a way that uses Mecanim automatically adds an Animator component.
When an Animator component is added for the first time, an Animation Controller is automatically created.




When you open the Animator editor, you can see that (1) the states are created automatically.
(2) Animation clips that are motion of each state are created and saved in the set path.




At this time, there is something you should be aware of.
AnyPortrait does not recognize Mecanim's "Empty State".
Therefore, you must use a state that contains a generated Animation Clip named "Empty".
When you want to use "Empty State", make sure to use state Animation Clip named Empty as Motion.




Edit the Animator by setting the Transition etc. in the Animator editor.
(Sub-State Machine and Blend Tree are not officially supported.)




Adding layers to Animator


Multiple animations can be set up as layers and run simultaneously.
It is possible to animate such as shooting while running or jumping.
AnyPortrait's existing animation script also supports layer functionality, and so is Mecanim.
You can add and configure layers in the following ways:




In Animator, add layers and configure the state machine.
Basically, it's a good idea to create an Empty state for "the state of the layer not merging".
As mentioned above, create a state using an Animation Clip named Empty.
Also set Blending and Weight.




Check the Mecanim Settings items in the apPortrait Inspector.
You need to modify the Mecanim information here.
(1) Press the Refresh Layers button.
(2) You can see that the layer you just created is added.
The Refresh Layers button should always be pressed if a layer is added, deleted, or changed in Blending mode.






Animator Override Controller


Animator Override Controller provides the ability to replace only animation clips while using Mecanim's Animator Controller.
Check out the explanation below on how to apply the Animator Override Controller using the animation clips automatically created by AnyPortrait.
(For more information about Animator Override Controller, see Official Manual.)




There are two characters with Mecanim applied.
(1) For Slime characters, (2) Mecanim with the above states is created.
(3) Let's implement a mecanim that behaves the same as this state on the Dragon character using Animator Override Controller.




The animation clips should be prepared in the same way as the animation of the character as a reference.
The length of the animation, etc., does not have to be the same.
Once you've enabled Mecanim and Bake each, you'll have animation clips created.




(1) Right-click in the Project window and select "Create > Animator Override Controller" to create a new "Animator Override Controller" asset.




(1) Select the created asset.
(2) Apply Slime character's Animator Controller to the Controller property.




Specifies the animation clips of the dragon character that correspond to the animations of the slime character, respectively.




(1) Select a dragon character.
If you turn on the Mecanim option and bake, the Animator component will be created.
(Otherwise, you need to manually add the Animator component or bake again.)
(2) Set the “Controller” property by replacing the existing “Animator Controller” with the “Animator Override Controller” created previously.




Now run the game and you will see the slime and dragon play while sharing the same state machine.