Sprite Animation

Creating Keyframe Animation Using Sprites in Unity

Grab your sprite sheet and roll up your sleeves! It's time to learn how to create basic animations using sprites in Unity. Before we start animating, make sure your sprite sheet is all set and sliced up in Unity. Our Sprite Sheet Setup tutorial can help with that if necessary. With that out of the way, let's begin.

First, make sure the Animation tab is ready on the editor. If you need to get the tab on your editor, click Window and select Animation. You can drag and drop the tab to your preferred area in the editor.

SpriteAnimation1

Let's make a game object with the sprite we want to use. Drag a sprite from your sliced sprite sheet into the scene.

SpriteAnimation2

With your game object selected, go to the Animation tab and click the Create button. This will give you a jumpstart to create the first animation clip for the game object. Select the folder you want it saved to, give it a name, and hit save.

SpriteAnimation3

Unity will automatically add the Animator component to your game object and create an Animator Controller for it alongside the Animation Clip. You can find the Animator Controller and Animation Clip you just created in the folder you chose under the Project tab. By default, the Animator Controller will have the same name as the game object you used. Double-click on it to open the Animator window.

SpriteAnimation4

You’ll see an arrow from the Entry state to the first animation clip you created. Right now, this is the default animation that will play when you launch the game. You can drag the states anywhere in the Animator tab to organize them. There’s a lot to know about the controller, and we’ll cover them in another tutorial about transitioning between animations. For now, let’s continue to get our first animation going!

Let’s go back to the Scene tab and select your game object. In the Animation tab, you can see the first animation clip is ready to be created. You can drag multiple sprites into the timeline together or one by one to begin creating your animation.

SpriteAnimation6

This will create the keyframes for every sprite you add (those blue dots in the timeline). You can individually drag each keyframe to change when it is played. Or, if you have all of the keyframes selected, you can drag the line at the ends to expand or shrink them together.

SpriteAnimation7

You can add or remove a sprite from the animation anytime to edit it.

SpriteAnimation8

Click play in the Animation tab to see it in action!

SpriteAnimation9

You can edit the animation using the technique above until you’re happy with it. And that’s it! You created your first Unity sprite animation! If you click play to run your project, you’ll see the game object play its default animation that you just created.

Level up your game development by finding more stuff to learn in our growing list of pixel-sized tutorials.