Tutorial: Unity Animation 3: Character Setup
These notes are taken from the Unity video series available on their website. This post deals with the tools available for adjusting the rigging of your characters, as well as creating masks to animate only part of your rig.
1: HUMANOID AVATARS.
In Unity, Avatars are definitions that tell the animation systems how to animate the transforms (bones) of a model. With your model selected, click the Rig panel in the inspector window. Animation Type can be set to Generic, Legacy or Humanoid. Humanoid can be reconfigured with Unity’s built in skeleton system. With Avatar Definition, you can create one from the selected model, or copy one from another avatar.
-Avatars are created as separate files in your project folder, that are then referenced by the animation system.
– Optimize Game Objects. By default, Unity does not optimize model rigging. This means that it will create an empty game object for every bone in the model. Checking the Optimize button will stop Unity from creating these objects, making your game run much more efficiently.
– Ocassionally, you will still want access to some of these transforms (bones) For instance, if you want the character to hold an object in his hand, have a gun attached to his hip or a helmet on his head etc, you link its position to the position of that particular bone. Underneath the optimize checkbox is an empty list titled ‘Extra transforms to Expose’. Click the ‘+’ symbol and then select the required bone from the list.
-If you change the optimization of the model, you will need to reconfigure its Avatar Definition, by pressing the Configure button below. You will be prompted to apply or discard the changes you have made. NB: Configuring is done in an empty scene, so Unity will ask if you want to save your current scene before starting the process.
-The configuration view shows the models Hierarchy of transforms (bones) on the left, and a green silhouette on the right in the Mapping tab, where unity will automatically try to map the bones to it’s humanoid template. Green circles are necessary bones, whilst dotted circles are optional. After making any changes necessary, click apply. The Muscles tab will allow you to preview your mapping in a variety of poses, as well as adjusting the movement ranges of the Avatar.
2: AUTHORING ROOT MOTION
– Root motion is the property that allows a character to keep walking forward along a line, rather than resetting to its initial position every time the walk cycle animation loops. In UNITY 5 it is possible to apply root motion without having to rely on scripting. To do this, you must first find the animation in the project panel, then click the Generate Root Motion Curves button in the inspector. Then, go to the gameobjects inspector panel, and in the Animator component check the ‘apply root motion’ box.
– This works by adding an offset to the objects transform position in worldspace every animation cycle, based on its final position in the animation. Otherwise, the object returns to its original worldspace position.
3: AVATAR MASKS
– In a model’s animations panel in the inspector, you can find the Avatar Masks tab.
– Avatar masks allow you to isolate part of a model to animate, so that the rest is ignored. This is useful for combining animations together, such as a shooting whilst walking or running. The upper body can use the shoot animation, whilst the lower body can use the run cycle animation.
– There are two ways to create an Avatar Mask:
Right click in the Project panel and choose Create > Avatar Mask. This Mask can then be applied to the Layers of an Animator Controller. This mask will then affect animation in that Animator Layer.
Alternatively, Select a model in the project folder and click the animations tab in the inspector window. Select the appropriate animation clip, scroll down to the Mask tab and click ‘Create From This Model’. This will create a mask specific to this animation.
– Once you have created your mask, select it in the project view to see its properties in the inspector. It has two tabs – Humanoid and Transform. Clicking on Humanoid will show a green human silhouette. clicking on parts of the body will turn them red. Red portions will not be affected by the associated animation.
– The Humanoid tab is very limited in what it can activate or deactivate. Using the Transform tab, you can choose any Avatar in your project file and check individual bones from the skeletal rig to activate during an animation. This is much more useful if you have characters with extra arms or legs, non humanoid anatomy etc.
#rigging #art #body #animator #gamedev #animation #character #development #game #animate #3d