Book Image

Unity Animation Essentials

By : Alan Thorn
Book Image

Unity Animation Essentials

By: Alan Thorn

Overview of this book

Table of Contents (14 chapters)
Unity Animation Essentials
About the Author
About the Reviewers


There's no getting around it! Animation plays a crucial role almost everywhere in games, from a simple scenario, such as a moving spaceship, to a complex scenario, such as facial animation. You simply cannot build a complete game and a truly interactive experience without some degree of animation. In this book, we'll take a step-by-step journey through the extensive feature set offered by Unity for creating real-time animations. We'll approach the subject from the ground up. This book assumes no prior knowledge about animation or experience in animation in Unity. However, it does assume basic familiarity with the Unity engine in terms of level design, basic interface usage, and some fundamental knowledge of C# coding. Using only this as the starting point, it proceeds to break down the bewildering range of animation features and considers their application in real-world scenarios, helping you achieve tangible results quickly and easily. Now, let's see what's ahead of us…

What this book covers

Chapter 1 , Animation Fundamentals, begins by considering animation formally as a concept—animation at its core. From there, this chapter considers miscellaneous and very practical cases of animation in Unity that specifically involve scripting. This includes working with deltaTime and animation curves and even animating Mesh UVs. Overall, this chapter marks the beginning of our journey through animation and features everything you need to know to move ahead.

Chapter 2, Sprite Animation, explores the world of 2D animation, examining the sprite feature set used to create 2D games, flip-book textures, and planar animation. We consider the Unity Sprite editor, animation frames, frame rates, and how to fix common problems.

Chapter 3, Native Animation, enables us to see animation more generally in Unity, for both 2D and 3D, using both the Animation window and Particle Systems. We look at two very practical and useful projects. First, we create a camera fly-through across a level. Then, we create a dust/firefly particle system, which is very commonly found in fantasy games.

Chapter 4, Noncharacter Animation with Mecanim, teaches you about a flagship feature of Unity, namely Mecanim. Mecanim refers to a collection of features that together make advanced and smooth animations possible, especially for characters. In this chapter, we see the more unconventional uses of Mecanim as we animate doors and other interactive elements in our levels.

Chapter 5, Character Animation Fundamentals, begins with an analysis of rigged character animation. In this chapter, we see how to animate humanoid skeletons and characters for real-time animation. We also consider how to import rigged characters and configure them optimally, ready for animation.

Chapter 6, Advanced Character Animation, follows logically from the previous chapter. Here, we take an imported and configured character in Unity, and then we animate it as a player-controlled character. This character will support idle and forward movement, for both walking and running, as well as turning animations for moving left and right.

Chapter 7, Blend Shapes, IK, and Movie Textures, marks the end of this book. This chapter covers the following topics: Blend Shapes, used to create facial animations and other morph-like motions; inverse kinematics, used to accurately position a character's feet and hands in real time; and movie textures, used to play movie files as a texture projected onto a geometry.

What you need for this book

This book contains almost everything you need to follow along. Each chapter considers practical, real-world projects for animation, and includes companion files that can be downloaded and used. The only thing you need, apart from this book and your concentration, is a copy of the latest version of Unity; at the time of writing this book, it's Unity 5. The Unity 5 software is available for free as a personal edition, and it can be downloaded from the Unity website at In addition to Unity, if you want to create rigged character models and other animated 3D assets, you'll also need 3D modelling and animation software, such as 3ds Max, Maya, or Blender. Blender can be downloaded and used for free from However, this book considers only animation in terms of Unity.

Who this book is for

If you have a basic understanding of Unity and are looking to expand your knowledge further, seeking to learn more about real-time animation, then this book is for you. This book assumes that you've already used Unity to build simple levels and write basic scripts and you're looking for something more, that is, understanding more advanced animation concepts. Specifically, you may want to learn how features such as Mecanim can not only help you create believable animation, but also make your work simpler and more efficient.


In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "By default, all new scripts are created with two functions, Start and Update."

A block of code is set as follows:

using UnityEngine;
using System.Collections;
public class MoviePlay : MonoBehaviour 
  //Reference to movie to play
  public MovieTexture Movie = null;
  // Use this for initialization
  void Start () 
    //Get Mesh Renderer Component
    MeshRenderer MeshR = GetComponent<MeshRenderer>();
    //Assign movie texture
    MeshR.material.mainTexture = Movie;
    GetComponent<AudioSource>().clip = Movie.audioClip; 

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

using UnityEngine;
using System.Collections;
public class Mover : MonoBehaviour 
  // Use this for initialization
  void Start () {
  // Update is called once per frame
  void Update () 
    //Transform component on this object
    Transform ThisTransform = GetComponent<Transform>();
    //Add 1 to x axis position
    ThisTransform.position += new Vector3(1f,0f,0f);

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Once the curve is constructed, give the code a test run by playing the Unity project, and see the effect it has in the Game tab."


Warnings or important notes appear in a box like this.


Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your account at for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from


Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to and enter the name of the book in the search field. The required information will appear under the Errata section.


Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.


If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.