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 SpiderIdle, Dodge, HitReaction, 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:
- Import...