Daily progress — having the Moss Giant stop at each waypoint.
The next challenge we’re given is to stop the Moss Giant from moving when the idle animation is playing. So it’s time to research how to check if a certain animation is playing in the Animator.
First thing I found while googling was this line:if (this.animator.GetCurrentAnimatorStateInfo(0).IsName("YourAnimationName"))
Seems simple enough! Let’s try to implement it.
I’ll first create a handle as I like to have components handy whenever I need them, remember that the animator component is in the child sprite object so we need to use GetComponentInChildren:

Next, I’m going to refactor the movement code in Update and place it in its own method called Movement()

Ok, time to finally implement the idle code:

So if the idle animation is playing, don’t do anything. Just return, but if it isn’t go ahead and run the movement method. Let’s try it out!

Noice!!! So all we need to do next is trigger the idle animation when we reach the other side! In order for everything to work correctly, we’ll have to set the default state to walk again as the idle animation is triggered when we reach a waypoint, and we start at a waypoint…

Then in the Movement function, we just set the idle trigger in our animator whenever the enemy reaches its destination.

Now let’s see if it works…

Excellent! The idle animation is triggered at each waypoint arrival and the creature stops for a moment before moving back!
One last issue remains and that’s having the enemy face the direction it’s walking when moving back. We’ll deal with that tomorrow!