Create a new Animator Controller in the myAnimators folder that you just created.
Now, click Add Component and search Animator on the Inspector tab to add it to unitychan.
Drag the AnimatorController from the myAnimators folder into the Controller field.
For Avatar, click the circle button right next to the Avatar field to bring up the selection menu and select “unitychanAvatar”.
Afterward, select a few animations from UnityChan > Animations and drag them into our myAnimations folder. For this tutorial, we will select the “unitychan_RUN00_F Import Settings”, “unitychan_WALK00_F Import Settings” and “unitychan_WIN00 Import Settings”.
Next, go to the Window>Animator or click the Animator in order to open the Animator window where you can create and modify the Animator Controller assets. The change of the animator states and transitions can be done by modifying the State Machine in the Animator window which is a kind of flowchart.
Drag the Run animation “unitychan_RUN00_F Import Settings” into the layout area of the Animator window. By default, the first animation you add will be the Layer Default State. There will be a transition connecting the Entry node to the Default node automatically. Therefore, the Run animator will be set as the state the State Machine start with. We will change the Layer Default State later.
THen, drag the remaining animations “unitychan_WALK00_F Import Settings” and “unitychan_WIN00 Import Settings” into the window.
To make the Walk animation become the Layer Default State, right click on “WALK00_F” state and select “Set as Layer Default State”. The orange colour indicates that the Walk animation is set to be Layer Default State and it would connect to the Entry node automatically.
After that, right click WALK00_F and select “Make Transition” to create a new transition between it and “RUN00_F”. Drag the transition to Run animation.
When the transition between “WALK00_F” and “RUN00_F” is created, click the plus icon on the Parameters view and select “Trigger” from the pop up menu to add a new parameter of type “Trigger”. The parameters view allows you to modify the Animation Controller Parameters which can define the act as inputs into State Machine.
Name the new parameter “run”.
Select the transition between walk and run which will then turns blue. Add a new Condition to the selected transition on the Inspector by clicking the plus icon. As “run” is our only parameter, it should be selected by default.
At the same time, add a transition from RUN00_F to WALK00_F such that the action can transit from running to walking.
We are now going to create a new trigger parameter on the Parameters view, naming it “walk”.
Again, select the transition that we just created(from RUN00_F to WALK00_F) and then select “walk” in the drop down menu.
For WIN00, create a new transition to Any State. Any State is a special state as it can change into the state you want at any state you are currently in.
For winning state, create a new trigger parameter and call it “win” this time.
After creating the transition, select it, add a new condition and choose “win” on the drop down menu.
Now the State Machine is all set. We can prepare to demonstrate different animations of Unitychan. First, drag the Animator Window to different part of the screen by holding the Animator tab so that you can see the Game scene and the Animator view at the same time.
Press the Play button to begin the walk animation, you can see that the WALK00_F is loading in the Animator window. It is because WALK00_F is the Layer Default State which would be played once the game is started.
While the game is playing, you can manually enable the triggers by clicking on the circular button next to them. In this case, we are going to trigger “run”, Unitychan would then transit from walking to running. The loading bar on the RUN00_F indicates that the run state is playing.
Also, try out the winning animation by performing the same steps.
You may also make use of C# script or Playmaker actions to set the Animator Triggers in Unity. However, if you would like to trigger change in animations in STYLY, please see our PlayerMaker tutorial which will show you the way to do it. Please note that STYLY does not support C# script.