In the past few years, Unity has proved itself to be a versatile, user-friendly platform for game production and other interactive applications. With it, developers can rapidly assemble game menus and interfaces, build levels, animate characters, and define how these elements interact with each other.
Compared to other development tools, Unity is artist-friendly, centering on a Scene viewport window and controls that will be familiar to anyone who has worked with 3D software. Like all game engines, it requires scripting to enable any complex functionality, but coding can quickly be tested and adjusted making for a less-frustrating experience for anyone from a non-programming background.
Unity's easy-to-learn drag and drop functionality has endeared it to enthusiasts and professionals alike. Its multiplatform publishing capabilities streamlined the creation of all sorts of games played on PC, Mac, iOS, Android and consoles.
The personal edition of Unity can be downloaded for free, making it suitable for entry-level game developers. The online manual and scripting reference, in addition to the thriving developer community, make it easy to find support and get queries answered.
The addition of Mecanim to Unity gives the independent game developer an even more expansive toolset, making it possible to handle a significant part of the character animation process without the use of additional software. It makes retargeting, retiming, and adjusting existing animations a simple task without the usual problems that accompany importing and exporting data between applications.
The modeling toolset within Unity is extremely limited—primitive objects such as spheres, cubes, and planes can be assembled—but if it is the actual modeling and texturing of characters and levels that you are most interested in, you will need a general 3D package such as 3ds Max, Maya, or blender. These aspects of building a game are well addressed in other publications.
In order to closely correspond to the development of a real game, the projects in this book follow a theme of a typical first-person action game—the sort that is often found to be played on PC, console, and mobile platforms—the context is the zombie apocalypse. During the game, our player must negotiate his or her way out of an office complex full of zombies. In terms of character animation, this will offer us plenty of variety in the type of movement required by the player and enemies.
This book will take the reader through the different processes involved in the character animation aspect of game development. It will explain the basic animation tools within Unity, as well as the dynamic Mecanim toolset and how it can be used in the game animation context.
Chapter 1, The Zombie Attacks!, introduces the Mecanim interface and explains how rigged characters can be imported to Unity and quickly set up with animation.
Chapter 2, Rigging Characters for Unity in 3ds Max and Maya, explains the relationship between the Unity engine and commonly used 3D software and how characters can be prepared within external software to function smoothly once imported to Unity.
Chapter 3, Interacting with the Environment, compares a few different strategies for making a character interact convincingly with the environment.
Chapter 4, Working with Motion Capture Data, walks you through the process of adapting motion capture files to animate your character with Mecanim's toolset.
Chapter 5, Retargeting Animation, considers the reuse of animation clips and how animation can be adapted within Unity to suit different character types.
Chapter 6, Talking Heads, demonstrates Mecanim's facial animation capabilities and the scripting necessary to get these working in a game.
Chapter 7, Controlling Player Animation with Blend Trees, explores more of the advanced features of the Animator panel, defining smooth blending between different animation clips with a limited implementation of scripting.
Chapter 8, Implementing Ragdoll Physics, compares the use of real-world physics with the character controller component and how these can both be implemented in a character setup.
Chapter 9, Controlling Enemy Animation with AI and Triggers, demonstrates how scripted behavior and Unity's navMesh navigation system can be used to control enemy character animations within a game.
Modeling, texturing of assets in 3D software, scripting game states, and GUI within Unity. These aspects of game development are beyond the scope of this book.
Understanding key animation concepts is necessary to complete the chapters in this book. In addition, you will need the following:
Unity 5 installed on your machine (Mac or PC). The free personal version of the software is sufficient for all of the project content in this book. This can be downloaded from the Unity webpage.
A little understanding of 3D software, x, y, and z coordinates, translating, rotating, and scaling elements within the Unity viewer interface.
A basic understanding of Unityscript or C# will be helpful to complete the projects, though the code that is included is clearly explained.
Additional 3D software is useful, but not required. The industry standards Autodesk Maya and 3ds Max both have free 30-day trials, which can be downloaded from the main Autodesk website. Blender is a free alternative.
This book focuses on the character animation aspect of game production in Unity.
If you are completely new to Unity, it is recommended to read through some of the basic introductory material documentation on the official site. If you have experience working with an older version of the software, then this book should give you a good idea of how Mecanim can be used in your pipeline.
If you are new to animation, this book uses some character animation terminology that you may not be familiar with. Where possible, I have explained these terms.
My approach to writing this book comes from an artist, rather than coder background. If your motivation for understanding character animation in Unity is to showcase your artwork in a demo or even a full-scale game, you have come to the right place!
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: "Choose an appropriate file name for the scene, such as Chapter1_1
."
A block of code is set as follows:
var health : int = 10; var healthLimit : int = 10; function AddHealth (increase : int) { health += increase; if (health > healthLimit) { health = healthLimit; }
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: "Click on the Model tab."
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.
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.
You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. 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.
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/B03192_ColoredImages.pdf
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 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.
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.