Book Image

Unity 2D Game Development Cookbook

By : Claudio Scolastici
Book Image

Unity 2D Game Development Cookbook

By: Claudio Scolastici

Overview of this book

<p>Unity is a powerful game development engine that provides rich functionalities to create 2D and 3D games.</p> <p>Unity 2D Game Development Cookbook is a practical guide to creating games with Unity. The book aims to serve the purpose of exploring problematic concepts in Unity for 2D game development, offering over 50 recipes that are easy to understand and to implement, thanks to the step-by-step explanations and the custom assets provided. The practical recipes provided in the book show clearly and concisely how to do things right in Unity. By the end of this book, you'll be near "experts" when dealing with Unity. You will also understand how to resolve issues and be able to comfortably offer solutions for 2D game development.</p>
Table of Contents (15 chapters)
Unity 2D Game Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Animation layers – creating masks


With Mecanim, it is also possible to blend animations for different body parts of a character. Let's see an example. You have a character that runs with a gun in its hand and you have a reload animation that the character performs each time its weapon is empty. When the character reloads, you want his upper body, actually its arms, to perform the reload action, while the lower body of the character, its legs, should keep running.

To achieve that in Unity, Mecanim features what are known as layers. Layers allow you to create masks for specific body parts of a character and apply animation clips only on those parts. A running animation that involves legs and arms can be blended with a reload animation that only involves the character's arms, the result being that the character keeps running with its legs, while its arms reload the weapon!

As layers require masks to work, in the next recipe, we will show you how to make one.

Getting ready

As we are not prototyping...