Tuesday, 26 August 2014

Animator Controller

Animator Controller
The Animator Controller is the main component by which animation behaviour is added to an object.

Creating an Animator Controller

You can view and set up character behaviour from the Animator Controller view (Menu: Window > Animator Controller).
The various ways an Animator Controller can be created:
·         From the Project View by selecting ‘Create > Animator Controller’.
·         By right-clicking in the Project View and selecting ‘Create > Animator Controller’.
·         From the Assets menu by selecting ‘Assets > Create > Animator Controller’.
This creates a .controller asset on disk, which looks like this in the Project Browser
Animator Controller asset on disk
Animator Controller asset on disk
After the state machine setup has been made, you can drop the controller onto the Animator component of any character with an Avatar in the Hierarchy View.
The Animator Controller Window
The Animator Controller Window
The Animator Controller window will contain
·         The Animation Layer Widget (top-left corner)
·         The Event Parameters Widget (bottom-left)
·         The visualization of the State Machine itself.
Note that the Animator Controller Window will always display the state machine from the most recently selected .controller asset, regardless of what scene is currently loaded.

Animation States

Animation States are the basic building blocks of an Animation State Machine. Each state contains an individual animation sequence (or blend tree) which will play while the character is in that state. When an event in the game triggers a state transition, the character will be left in a new state whose animation sequence will then take over.
When you select a state in the Animator Controller, you will see the properties for that state in the inspector:-

Property:
Function:
Speed
The default speed of the animation
Motion
The animation clip assigned to this state
Foot IK
Should Foot IK be respected for this state
Transitions
The list of transitions originating from this state

The default state, displayed in brown, is the state that the machine will be in when it is first activated. You can change the default state, if necessary, by right-clicking on another state and selecting Set As Default from the context menu. The solo and mute checkboxes on each transition are used to control the behaviour of animation previews - see this page for further details.
A new state can be added by right-clicking on an empty space in the Animator Controller Window and selecting Create State->Empty from the context menu. Alternatively, you can drag an animation into the Animator Controller Window to create a state containing that animation. (Note that you can only drag Mecanim animations into the Controller - non-Mecanim animations will be rejected.) States can also contain Blend Trees.

Any State

Any State is a special state which is always present. It exists for the situation where you want to go to a specific state regardless of which state you are currently in. This is a shorthand way of adding the same outward transition to all states in your machine. Note that the special meaning of Any State implies that it cannot be the end point of a transition (ie, jumping to “any state” cannot be used as a way to pick a random state to enter next).
Animation Transitions
Animation Transitions define what happens when you switch from one Animation State to another. There can be only one transition active at any given time.
Property:
Function:
Atomic
Is this transition atomic? (cannot be interrupted)
Conditions
Here we decide when transitions get triggered.
A condition consists of:
·         An event parameter or an Exit Time, specifying a number which represents the normalized time of the source state (e.g. 0.95 means the transition will trigger, when we’ve played the source clip 95% through).
·         A conditional predicate, if needed (for example Less/Greater for floats).
·         A parameter value (if needed).
You can adjust the transition between the two animation clips by dragging the start and end values of the overlap.

 

No comments:

Post a Comment