Nerd For Tech
Published in

Nerd For Tech

Animating our Player Part 1

Now that we have our player’s movements set up, let’s get to work on adding a bunch of the different animation that we will be using for it. In order to keep our workspace clean, we will want to create an animations folder within our player in the project tab so that we know these animations belong to that particular asset.
To start, we are going to add in our Idle animation. To do this, we will want to create a new animation track for the player and drag and drop the animation frames:

When playing our animation, we can notice that our character’s idle animation is playing rather quickly, so let’s see how we can lower the rate:

What we will need to adjust is our samples. If we don’t have it showing up on our animation window, we can simply add it there by going to the menu on the top right and selecting show sample rate.
Now that we have our idle animation in place, let’s get to work on some running animations. First, we will create the animation for our running state and make any adjustments we see are needed:

When we have added in the animation and look to adjust the rate, we are met with a clunky looking run. This is because of the method we used to slice the different sprites. To fix that, we just have to re-slice it:

Now that our run animation has been smoothed out, let’s see how we can get it working through code. To start, we will need to create a parameter to work with:

For our parameter, we are going to set our idle to be triggered if our movement is < 0.1, and to run it will start at a value > 0.1. Now that we have our parameter set up, we can now move to the scripts to get it all set up:

What we have done here is simply set up our animator so we can control our various animations we will be running. For the running animation, we are going to set it up so that we get the absolute value of our move. This will allow our player to run if we decide to move to the left. Without using Mathf.Abs, what will happen is anytime our player moves left, it will just stay in the idle state. Finally, we will need to just add into our player script the method in which to give this animation it’s value:

With this set up, we can now see if it works with our game:

Now that we have our running animation in place, we need to quickly add in the ability for our sprite to flip around when it starts to move in the other direction:

What we will be doing is using the flip along the x axis depending on the value of the direction we are going:

Now that we have a running sprite, let’s see how we can go about creating our animation for the jump process.
First, we will need to get our transitions set up. For most of the transitions, it will simply be setting the bool to either true or false, however, with our jump to run transition, we are going to set an additional parameter to it:

What this does is not allow both the transition from jump to idle or running be the same. From here, we are going to need to get to work on our code. To start, we will create our void within the Animation script:

As to where we are going to call our statement true or false, let’s start with our true. We will simply have it called when we jump:

Next, for our false statement, we are going to add it within the IsGrounded void:

With this all set up, let’s see how it looks in our game:

Now that we have our basic animations in order, we can move on to getting some attack based animations in place.



NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store