Animator Controllers contain one or more
state machines that determine which animations
are currently being played.
These states are controlled by parameters
which get their values from scripts.
To create an animator controller
click the Create menu in the Project view
and select Animator Controller.
You can also just right click any blank
space in the Asset view and select
Create - Animator Controller.
Animator Controllers are managed
through the Animator window.
To open the Animator window either click
Window - Animator
or double click on any animator controller asset.
This window is resizable and dockable
allowing you to place it wherever makes the
most sense for your workflow.
Parameters are created by clicking the
plus icon next to the word Parameters
in the bottom lefthand corner of the Animator Window.
They can be either floats, ints,
Booleans or triggers.
Parameters generally represent qualities of
an animation or decision making condition.
For example, if you are animating a
humanoid's movement a common approach
could be to create a float parameter for Speed.
When the Speed parameter is large
the animator controller can be made to
transition the states with faster animations.
States can be made in one of three ways.
The first way is to drag an animation clip
from your project panel on to some
empty space in the Animator panel.
This will create a state who's motion
is that of the animation clip
that was dragged on.
The second way is to right-click on some
empty space in the Animator panel
and select Create State.
>From here you are given three options.
Empty, From Selected Clip and
>From New Blend Tree.
For information on Blend Trees
see the lesson linked below.
An empty state is simply one that does
not have any motion.
These can be useful as they do not mask
animation that is being played on other layers.
For information on Animator Layers
see the lesson linked below.
To create a state from a selected clip
you must have the animation
you wish to make in to a state
highlighted in the project panel.
The third way to create an animator state
is to create an animation
in the animation window.
This is separate and distinct
from the animator window.
When you create the animation
It will create a state for it
in the base layer of the animator controller
that the animation is being created for.
The Animation Window is covered in it's
own video linked below.
The first state created on any layer
will become the default state
which is shown by the state's colour being orange.
You can change which state is default
by right-clicking on the state you wish
to be default and selecting Set As Default.
The default state is the one who's animation
will be played to start with.
To edit states in the Inspector panel
simply click on them.
At the top we can specify a name
and a tag for the state.
Both can be referenced through a code
if you want to perform any actions
while in specific states.
So it is a good idea to set those
to something meaningful.
The Speed property refers to how fast
the animation plays compared to it's
normal playback speed.
A value of 1 indicates normal speed.
The Motion property is the particular
animation clip for the state.
Foot IK stands for
Foot Inverse Kinematics.
If this option is checked
it will reduce or eliminate
any foot slipping in your animation.
The Mirror property simply flips the
animation left to right.
Below this is a list of transitions
from this state to others.
Currently there aren't any,
so let's look at creating some.
A transition allows our animator controller
to smoothly move from one animation clip
to another.
We can specify when and how to transition
which gives us a high level of control.
To create a transition between states
right-click on a state that you wish to
transition from and select Make Transition.
You will then have a transition arrow
attached to your cursor.
Click on another state to complete the transition.
You can click on the transition
to edit it in the Inspector.
Each transition has the options
Solo and Mute.
Mute effectively disables the transition
Solo takes in to account all the transitions
that come from the same state
and effectively mutes all those
that aren't marked as solo.
Mute and solo are tools for debugging
and focusing on particular areas of state machines.
They should not be checked
on any published builds.
Beneath those properties you have the option
of naming the transition.
Under that you have the Atomic Property.
If the atomic property is checked
it means that the transition is
not interruptible by other transitions.
The graph shows how the animation
is handled during the transition.
The scale is in seconds and frames.
There are three markers on the scale.
They represent the start and end of the
transition in time and the scrubber
for previewing the animation of the transition.
Between the start and end marker
is a blue shaded region which represents
the transition from one animation to the next.
The graph curves represent which foot
is the most stable over time.
For a state with a running animation
we'll see a curve changing from up to
down and back.
If the line is in the centre,
for example in an idle animation,
then neither foot is more stable.
For a smooth transition
try to get the lines to match up.
If neither foot is more stable
then this is less important.
You can move the two states
back and forth in the graph
to adjust at what points the transition
starts and ends.
Below the graph is where we specify
the conditions that will cause this
transition to run.
By default transitions have a
condition of an exit time.
This means that once the animation
of a state is a portion of the way through
it will transition to the next state.
Conditions are generally dependent on parameters,
for example a Bool parameter being true or false
or a float parameter being greater than
or less than some constant value.
A transition can have multiple conditions
if required.
Click the + button to create more.
At the bottom of the Inspector
there is a preview window for viewing
what the transitions look like.
It is possible to have multiple transitions
to and from the same state.
Generally this is used to have multiple
sets of conditions for the same transition.
Consider having a Speed parameter
and two states Idle and Run.
To have the condition that you transition
from Idle to Run
when Speed is not 0
you could create two transitions
and have the conditions be
Speed is greater than .1
and Speed is less than -.1
Subtitles by the Amara.org community