Flipping and Triggering Our Moss Giant!

addam davis
3 min readDec 1, 2021

--

Objective: Trigger the Idle animation for the Moss Giants and flip the Moss Giant to face the right way when walking.

In the last tutorial we created a waypoint system for our Moss Giant to walk between. In this tutorial we are going to focus on flipping the Moss Giant so we is facing the right way when walking, triggering the idle animation and preventing the Moss Giant from moving while the idle animation is playing.

Let’s begin with triggering the Idle animation. When the Moss Giant reaches a target we want to trigger the idle animation.

Great! Now we want to flip the Moss Giant when they are walking to the left so they are facing the way they are walking. to do this we need to use our reference we have to the sprite renderer.

Now in the movement method we need to check if the current target is equal to point a, if so then flip the x axis, else don’t.

Now we need to prevent the Moss Giant from moving while the idle animation is playing. One method we could employ is use get current animator state info.

The layer Index is set to 0 for me and is located here on the animator view.

A method to have our Moss Giant do nothing is by using the keyword return. By using the get current animator state info, and checking if the name of the state is Idle we can return. Meaning while the name is Idle the Moss Giant will do nothing, then below that we call the movement method.

Now let’s test it.

We’ve done it! Our monster will now walk between waypoints. Once they reach a waypoint they stop moving and play their idle animation, then they turn around and make their way to the next waypoint. Don’t be afraid to experiment with your setup, and I’ll see you in the next tutorial!

--

--