Unity 5 Animation Control Meta-Tutorial
In this Meta-Tutorial* I will be walking through the Unity 5 Animation Control tutorial by Aaron Hibberd. The tutorial was made in August 2015 using Unity3D 5.1.2f1 (from 2015) but I will be using Unity3D 5 2017.1.
* Meta-Tutorial – a walkthrough of a tutorial which shows the ins and outs and ups and downs of the tutorial and proves out that it isn’t too ‘rotten’ (see tutorial-rot in my other articles)
Part 1: Setting up the project
In this section Aaron talks about why he is creating the video and downloads a great character called “Unity-chan!”.
Warning Pop Up:
He shows you how to download Unity Chan but I noticed one thing that happened for me but not for him: I got a warning pop-up from the asset store indicating that Unity-Chan was created for Unity 4.6 and therefore some scripts may not work with Unity 5.
I am going to choose to ignore that warning since Aaron has made this tutorial specifically with Unity 5 in mind so I believe he will address most or all of the compatibility issues necessary to complete the tutorial.
Unity-Chan has her own EULA (End-User License Agreement)!
I bet if I keep my eyes peeled for this I’ll see more examples of it but I haven’t previously seen an asset having a license that they made just for that asset and to me that is kind of cool and it means they take their asset seriously as a product in and of itself.
I like how Aaron is showing the steps clearly and fast and not wasting time waxing poetic about his opinions about what is going on and why which should allow him to get through more tutorial content in a tighter video package and I appreciate that. He also edits the video to remove any dead space that was previously there.
In this section we are asked to make an ‘animator’ to control the animation. This is entirely new to me so I’m glad he explained adding the animator window. He’s walking us through this with an excellent understanding of what exactly we need to know.
At this point while you are in play mode (and once you have unchecked maximize on play) if you right click on any of the wait animations in the animator window and select ‘Set as Layer Default State’ you can see that animation take over instantly. Unity’s real-time response to changes and updates like this is remarkable and powerful.
He shows you how to transition from one animation to another and how to set a default, and then how to write a simple script that will soon let us control our animations but when he is compiling and running the first script at first I was concerned about all of the warnings I saw in the console but I see in Aarons window that he has many or all of the same warnings which I believe come from the Unity-Chan scripts not being completely up to date with the latest version of the API and everything works fine.
Here’s a simple ‘gotcha’ thats worth looking out for
I noticed that the first time I dragged the script onto my unity-chan character it seemed to add that component to the character but the next time I hit ‘run’ the script was no longer attached. This was because I had dragged it while I was still in ‘run’ mode and changes made while you are in run mode are not maintained. Once I dragged it over when I was not in run mode it attached and worked well.
What can you do with those animations
He explains what the final parameter is in the anim.Play command and shows what happens when you change that value to 0.5f. He also shows how to get input from keys, the mouse, and from the default input controller (no matter what that is configured to be) and how to use that information to trigger different animations, even choosing an animation randomly from between several possibilities. He shows how to pass floats via public attributes in the script through to the animator and how to see them update live as you press your input keys
I experimented with the ‘mirror’ property in one of the animations and it seemed to flip left to right but also to start the animation at the end and work backwards.
He shows how to create a new state machine from a blend tree and how to descend in to that state machine and then how to make a 2d simple directional walk animation and then adding a ‘motion field’ and how to use that field.
Once he got the wait states working he added a script to move the character based on all of the directions. He showed how to change the character to a physics object (added a rigid body) and how to add forward and backward motion and limit velocity when the character isn’t being animated. He showed how to add run animations based on a boolean parameter which was based on having the shift key depressed and how to make her move faster when the shift key was depressed. Finally he shows how to implement a jump and then slide animation.
Overall this was an effective and tight tutorial showing everything clearly and without fluff or wasted time. It gives you a good understanding of the Unity animator state machine system and with this you could code up some really complex and interesting characters. Even though the tutorial was made in 2015 there really weren’t any stumbling blocks and certainly no show-stopping issues and I am grateful to Aaron Hibbard for creating this video.
Thank you for reading and please check out the other tutorials and meta-tutorials on this site.