Join Sue Blackman for an in-depth discussion in this video Understanding the Animator Controller component, part of Animating Characters with Mecanim in Unity 3D.
- View Offline
At this point, we've configured the avatar and set up animation clips for one of the characters. The next step is to create the animator controller. This is how we access Mechanims powerful state engine. Once set up, it can be used to control various different characters. To create one, we need to open the right-click menu, and from Create, all the way down near the bottom, select Animator Controller. And a new one is created for us. Let's name this one test controller.
Has a nice icon, but there's nothing showing in the Inspector. Turns out the animator component is a fairly complex critter. It has an entire window of its own with individual elements that use the Inspector. To open it for the first time, we could go the Window menu and select it, or we could just double-click on it. It opens in a tab next to the scene view in the two by three layout. Now I'm going to give myself a little more space. By default, it's showing the base layer as you can see in the title bar in the upper left.
The name of the controller is shown at the bottom right. Testcontroller.controller. In the top left is the layers section. Layers will allow you to use masks to override parts of the current animation. An example is a character that is in walk behavior where the layer using an arm mask will allow just the arm to play a different behavior, such as waving his arm or shooting his weapon, all while still walking. You can create a new layer by clicking the plus in the layers bar.
You'll need to navigate the layer using the scroll bar, because you can't size this guy. It will get bigger if you add more layers to it, but it has a limit. To delete the layer, click on the minus sign. For those of us who are used to closing roll downs with the minus sign, Unity added a query box to make sure that's what you wanted to do. Because, as the message says, you can't undo this action. In the lower left is the parameter section. You click on the plus sign and are immediately asked to choose what type of variable you want. We have a choice of vector, that's your basic multi-part variable, xyz, rgb, rgba, that kind of thing.
And you also have floats, ints, integers, or bools, Booleans. After choosing, you can set their initial values and name them. To get rid of them, click the minus sign. This time there's no warning, because they aren't being used yet. And finally we have the state window. You can navigate the window with the regular pan controls. Middle mouse down, or alt and left mouse. And rolling the middle mouse roller pans the view up and down. The only thing in it so far is the any state.
It allows your character to transition into a particular state, such as a dead state from any other state without having to hook it up to each state individually. So this is pretty much the basic layout of the animator controller window.
- Importing characters and setting scale
- Setting up the controller
- Creating transitions
- Scripting the controls
- Adding layers and layer masks
- Handling nonhumanoid appendages
- Configuring blend trees
- Controlling states with speed
- Adding a multistate jump
- Targeting with IK (inverse kinematics)
- Setting up generic rigs
- Testing the character in the game