Animation

Animation Systems

In Unity, two systems can be used for animation

  1. The legacy animation system. You will be controlling your characters on a very granular level
  2. The new Mecanim animation system and get to play with the new and powerful Animator controller

Animation Basics

Animations are premade sets of visual motions

The Rig

Animating a model without a rig is impossible (or impossibly difficult). The reason is that without a rig, the computer has no way of knowing which parts of a model are supposed to move and how they are supposed to move. The rig dictates the parts of a model that are rigid, which are often called bones. It also dictates which parts can bend. These bendable parts are called joints

Note: 3D Artists Wanted

Generally speaking, the modeling, texturing, rigging, and animations are all created by professionals known as 3D artists in programs such as Blender, Maya, 3D Studio Max, or any other 3D creation software

Preparing a Model for Animation

In this section, you begin working with a model that has already been rigged, and you acquire animations specifically made for the model. You acquire a model from the Unity Asset Store

To access the Unity Asset Store, click Window > Asset Store. You may be asked to log in. Once the Asset Store is loaded, locate the search window and search for Warrior

Locate the free model 3dsmax Bip Warrior Anim Free and click Import (see Figure 17.3). When the Import Package dialog appears, ensure that everything is selected and click Import.

You should now notice a new folder on your Project view named 3dsmax Bip Warrior Anim Free

Demo

The soldier model comes with a demo scene. You can find this demo in the Scenes folder under the folder 3dsmax Bip Warrior Anim Free. Opening this scene will allow you to test out the model with the various animations applied

The Model

You can locate the model that you will be using in the Models folder under the newly created 3dsmax Bip Warrior Anim Free folder. The model is named Soldier_f_0. Locate the model and select it. In the Inspector view, you should see three primary tabs: Model, Rig, and Animations

The Model tab is responsible for all of the settings that dictate how the model itself is imported into Unity

Under the Rig tab, ensure that the Animation Type property is set to Legacy and that the Generation property is set to Store in Root (New)

Under the Animations tab, uncheck the Import Animation check box, and then click Apply.

Is the Model Rigged?

You can always look at the model in the Hierarchy view. Generally, a rigged model will contain several child game objects. These objects will correspond with the various rigging joints.

Animation Assets

Locate the Animations folder under the 3dsmax Bip Warrior Anim Free folder. This folder contains four available animations: death, idle0, idle1, and idle2. Selecting any of these animation assets will allow you to modify their Wrap Mode property and preview them.

Adding Animations

As mentioned previously, animations can be applied to a model by dragging them onto the Animations property of the Animation component

Wrap Modes

Scripting Animations

To play an animation on a model, you need to use the transform.animation.Play() method