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

Keyframe sprite animation


Now, let's learn how to create a simple attack animation clip for our sprite character using keyframes instead of a spritesheet.

Keyframe animation is a complex topic, and we cannot fully address it in a single recipe. Nevertheless, we'll use this opportunity to cover the basic principles so that you can get a grasp of the procedure.

Getting ready

Again, we keep up from where we left. Have your project open and be ready to follow our instructions.

How to do it...

  1. Open the Animation panel by going to Window | Animation, as shown in the following screenshot:

  2. Select Character in Scene. Then click on the drop-down menu in the Animation panel to set attack as the active clip, as shown in this screenshot:

  3. Set a reasonable number of keyframes for the attack clip; 24 frames per seconds is a good starting point. Then hit the recording button to start recording the clip. You can refer to the following screenshot to ensure that you are doing it right:

  4. With the record button pressed...