Daily Progression — Setting Up Player Animations
The next task was to bring life to the static player sprite, There are quite a few animations to go through, but I’ll share importing the idle as a refresher and it has all the steps needed for a reminder:
Open Unitys Animation window and set it into the game scene area.
Then select the players sprite object, and in the animation window click on “create animation”. Save it in the players sprite directory under animations as “player_Idle” or something similar.
I don’t think we need the tile palette anymore so I’m going to close it to give room to the animator.
Much better! Now if you look into the Animation director, there’s the PlayerIdle that we still need to populate with animation frames, and in the inspector, in the Animator section, we see an Animation controller named Sprite. This is the controller that’s being used in the player sprite now and if you double-click on it, it will take you into Mecanims animator( or you can always open the Animator Window manually, there’s more than one way to do most things in Unity!) which we’ll be getting more into later.
Putting the animation into the player is actually pretty easy, just drag all of the sprite frames into the animation window. Give Unity a few moments to process everything and then you’ll be able to press the play button and see your player in action!
It’s playing at around 60fps which is a little too fast. Let’s halve that to 30fps.
That’s a lot better!
Adding a new animation is a lot easier now that the animator is set up. Just go into the animation window, and with the player sprite selected, hit the drop-down menu where Player_Idle is and select “Create new clip”, in this case, we’re going to make Player_Run and save it in the same Animation directory.
If you check the Animation window, you’ll see that it’s created a Player_Run state as well.
And that’s pretty much all there is to it! There are more animations to put in like run, attack, jump, etc. And you implement them all the same way, so once you know how to go through these steps, you’ve mastered the process of animating sprites in Unity! This is of course only one step. We got the animations in, but now we need to make transitions between them! Stay tuned, we’ll learn all about that tomorrow!