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

Checking what Animator state is currently active to disable or enable player actions


There are situations when we need to block or allow certain actions depending on the currently played animation. This recipe describes how to easily check what animation is currently being played.

Getting ready

We are going to use the same Spider character from the previous recipe. It has SpiderIdleDodgeHitReaction, and Death animations. You can open the provided example project and go to the Chapter 06 Handling combat\Recipe 05 Checking what animator state is currently active to disable or enable player actions directory. There is a Spider character in the Example.unity scene. When you press the H key, it will start a healing action, only when in SpiderIdle state. You can find all the necessary animations in the Chapter 06 Handling combat\Recipe 02 Using animation events to trigger script functions\Rigs directory.

How to do it...

To check which Animator state is currently active, follow these steps:

  1. Import...