- Create a “generic” and “simple” animation set using Mixamo animations with names like “attack” rather than “RPG-Sword-Attack-01” so that the override controller just works better.
Importing from MIXAMO
I decided to use the Astra model along with the Sword and Shield Pro animation set. I created a project for working only with the animation controller in an effort to keep the system separate from the other work that I am doing.
After importing the meshes from Mixamo I had to immediately make a couple edits. First, the character’s textures did not import properly. The first step in solving the problem is to select the raw imported mesh and, from the Materials tab, extract the textures. You might also need to switch the Location to “Use Embedded Materials (Legacy)”.
The next step is to get the animations to preview using the imported character model. We are going to need an avatar for this so again from the imported raw mesh, on the Rig tab, select Humanoid for the Animation Type and Create From This Model for the Avatar Definition. Click Apply to create the avatar.
Now that we have the Avatar created we need to set up the animations. Select all of the imported animations and, from the Rig tab, set the Animation Type to Humanoid, the Avatar Definition to Copy From Other Avatar, and the Source to the avatar created in the previous step.
The Animation System
I have previously created a “simple” animator controller from the portion of the RPG tutorial that I’ve already finished. The goal is to set up the Mixamo animations to use simple names so that any override controller will show those simple names.
Speed controls the Movement state of the character. 0 for Idle, 1 for Walk, or 2 for Run.
Attack and Interrupt are used to ensure proper control over the Attack animation.
Die and Resurrect are used to ensure proper control over the Death animation.
Left Handed is a flag hooked up to the Mirror attribute for the animation states.
The video below shows the process used to get the animations looking good in unity, though that can be difficult with the Mixamo animations.
I noticed that there were some rotation issues with the animations. I show how to correct these in the following video:
Setting Up a Character
Characters are set up in three layers. The easiest way to get one going would be to drag in the sample Paladin sample prefab.
Otherwise, create an empty Game Object then drag the Animator prefab under the empty Game Object. Add a mesh as a child of the Animator Layer prefab.
Set the Controller and Avatar on the Animator component. The Avatar can usually be retrieved from the Mesh prefab. Use the Simple Character controller or else create your own.
The Attack Animator and Death Animator components require no additional setup but both have event handlers that denote the end of their respective animations.
In order to trigger the Dying Ended event from the Death Animator, you will need to add an Animation Event called “DyingFinished” to any Death animations that will be run on the character.
The Movement Animator needs to reference the outer most Transform of the character. This is part of the computation to set the speed of the blend tree.