Book Image

Unity 5.x Animation Cookbook

By : Maciej Szczesnik
Book Image

Unity 5.x Animation Cookbook

By: Maciej Szczesnik

Overview of this book

This recipe-based practical guide will show you how to unleash the power of animation in Unity 5.x and make your games visually impeccable. Our primary focus is on showing you tools and techniques to animate not only humanoid biped characters, but also other elements. This includes non-humanoid character animation, game world creation, UI element animation, and other key features such as opening doors, changing lights, transitioning to different scenes, using physics, setting up ragdolls, creating destructible objects and more. While discussing these topics, the book will focus on mecanim, the Unity 3D animation tool, and how you can use it to perform all these tasks efficiently and quickly. It contains a downloadable Unity project with interactive examples for all the recipes. By the end of this book, you will be confident and self-sufficient in animating your Unity 3D games efficiently.
Table of Contents (17 chapters)
Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Preface

This book describes Unity's animation techniques from a designer's point of view. It is focused on achieving interesting gameplay effects and creating game mechanics. Each topic is presented in the form of a short recipe with a list of steps needed to implement the given feature. All the recipes are prepared in the most condensed form—a good basis to build your own solutions on.

This book doesn't cover animating in a 3D package, although you may find some helpful tips regarding Blender 3D in it. A lot of the recipes presented in this book use C# scripting not only for triggering animations, but also for creating interesting motions and effects. If you are a game designer or a Unity developer and would like to know more about what's possible with Unity's animation system, I hope this book will be an interesting read for you. Also, if you have any questions regarding this book or the topics it covers, you can contact me via Twitter (@MaciejSzczesnik). I will be happy to help.

What this book covers

Chapter 1, Working with Animations, describes the tools essential for importing animations from 3D packages. It also covers most of the import settings.

Chapter 2, Working with the Animation View, covers Unity's built-in animation tool, used to animate almost everything apart from characters.

Chapter 3, 2D and User Interface Animation, focuses on animating 2D sprites and UI elements.

Chapter 4, Character Movement, covers different types of movement, using animations and root motion.

Chapter 5, Character Actions and Expressions, is about actions, action points, and facial expressions.

Chapter 6, Handling Combat, covers combat-specific topics, such as using animations for aiming and creating a hit-detection system.

Chapter 7, Special Effects, is not only about particle systems, but also about animating fog, creating wind zones, and even using sound waveforms for animation.

Chapter 8, Animating Cutscenes, describes how to import a cutscene from a 3D package and how to prepare simple cutscenes using Unity's Animation View.

Chapter 9, Physics and Animations, shows how to create ragdolls and break stuff.

Chapter 10, Miscellaneous, is the last chapter and describes a few solutions to common problems—for instance, working with mocap animations in Blender and Unity.

What you need for this book

You need to install Unity 5.x (preferably 5.3 or greater). You also need to have your own animations or download the provided example project. It contains the assets needed to follow each recipe.

Who this book is for

This book is for Unity developers who have some exposure to Unity game development and want to learn the nuances of animation in Unity. Previous knowledge of animation techniques and mecanim is not necessary.

Sections

In this book, you will find several headings that appear frequently (Getting ready, How to do it..., How it works..., There's more..., and See also).

To give clear instructions on how to complete a recipe, use these sections as follows:

Getting ready

This section tells you what to expect in the recipe and describes how to set up any software or any preliminary settings required for the recipe.

How to do it…

This section contains the steps required to follow the recipe.

How it works…

This section usually consists of a detailed explanation of what happened in the previous section.

There's more…

This section consists of additional information about the recipe in order to make you more knowledgeable about the recipe.

See also

This section provides helpful links to other useful information for the recipe.

Conventions

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: "Simply drag and drop the file to yourAssetsfolder."

A block of code is set as follows:

using UnityEngine; 
using System.Collections; 
 
public class Wave : MonoBehaviour { 
//The anim variable is used to store the reference 
//to the Animator component of the character. 
private Animator anim;

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: "Go to AssetsImport new assetand choose your FBX file."

Note

Warnings or important notes appear in a box like this.

Note

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 [email protected], 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 www.packtpub.com/authors.

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 for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.
  2. Hover the mouse pointer on the SUPPORT tab at the top.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box.
  5. Select the book for which you're looking to download the code files.
  6. Choose from the drop-down menu where you purchased this book from.
  7. Click on Code Download.

You can also download the code files by clicking on the Code Files button on the book's webpage at the Packt Publishing website. This page can be accessed by entering the book's name in the Search box. Please note that you need to be logged in to your Packt account.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows
  • Zipeg / iZip / UnRarX for Mac
  • 7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Unity-5.x-Animation-Cookbook. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

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 https://www.packtpub.com/sites/default/files/downloads/Unity5xAnimationCookbook_ColoredImages.pdf.

Errata

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 http://www.packtpub.com/submit-errata, 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 https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

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 [email protected] with a link to the suspected pirated material.

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

Questions

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