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

Creating Blend Tree


A very useful feature of the Mecanim system is the Blend Tree, which allows you to easily blend between two or more clips that can be controlled by a single float value. In fact, what if we plan to have our character switch between the idle, walk, and run states? With a Blend Tree, we can have the character's speed value take control of the conditions to switch between them, more or less as we did to switch between walking and running.

Follow us with the next recipe to learn how to use Blend Trees!

Getting ready

As we don't want to mess up the clips and transitions we created in the previous recipes, let's assume we are working with a clean animator controller. You can create a new one or clear the one we worked on before.

How to do it...

Access the Animator panel in Unity.

  1. Right-click anywhere in the window (which should only contain the Any State box) and select From New Blend Tree under Create State, as shown in the following screenshot:

  2. Double-click on the Blend Tree you...