What is the Animation Now?- Game Dev Series 103

S.J. Jason Liu
2 min readAug 7, 2021

--

Quick guide: check Animator state to proceed code.

So far we controlled Animator from Player movement for many times. And what if we want to control the movement from Animator? Like stop walking when Animator state into Idle, and walking when transition to Walk state.
We can easily do this part by using the default bool of Animator reference.

Get current state of Animator

To do this part, we will need to use Animator.GetCurrentAnimatorStateInfo().

It requires the layer integer of Animator, which is 0 on base layer by default.

In my case, if I want to make it check the state is “Idle” or not, use it like this:

I can simply add this line before the Player movement method to prevent the code proceed.

It will continue the following script when Idle is finished playing.

And that is how to check the state of Animator.

--

--

S.J. Jason Liu
S.J. Jason Liu

Written by S.J. Jason Liu

A passionate gamer whose goal is to work in video game development.

No responses yet