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

Using Animation Events to draw a weapon


Another common case in combat mechanics is drawing and sheathing a weapon. In this recipe we will use Animation Events along with a Draw animation to make our character draw and sheath a sword.

Getting ready

To follow this recipe, we need to have a Warrior character with two animations: Idle and Draw. The first one is a standard, looped Idle animation. The second one is an animation in which our character reaches for their weapon in a sheath attached to the character's belt. We are not using a sheath model here to make the recipe more simple and condensed. You can open the provided example project and go to the Chapter 06 Handling combat\Recipe 06 Using animation events to draw a weapon directory. There is a Warrior character in the Example.unity scene. When you press the space bar, it will draw or sheath a sword. You can find all the necessary animations in the Rigs directory.

How to do it...

To make a character draw or sheath a weapon, follow these steps...