Animating Sprites in Unity

We’ve got some Powerups created, and during that process you may have noticed there were a bunch of additional sprites in their respective Powerup folders.

Those Sprites are reserved for the Animation process!

Animating 2D sprites is pretty simple if you already have the assets (creating them is the hardest part!). It’s like stitching together a stop motion video! Just a bunch of pictures (sprites) played in sequence. Here’s how we go about doing that in Unity:

Our Powerups really stand out now!

The Animation Window

In the default layout, the Animation window is not set up, so we have to open it ourselves. It’s as simple as going into the Window tool bar and clicking the Animation window (or hotkey CTRL + 6).

I like to drag it beside my Game Window so that I can see the animation in the Scene window when editing.

The Animation window is where we will import our sequence of Sprites to create an animation!

Opening the Animation Window

Creating an Animation

Now that we have access to the Animation window, let’s utilize it!

First we have to click on the Object we want to create the animation for. In this case, since our Triple Shot Powerup is a prefab, we’ll click on that in our Project Window.

Having your Animation Window open, you should see a CREATE button after selecting your Object. Click on that, and give your animation a name; I tend to name it exactly what it is, followed by the suffix _anim.

Create a new animation.

Now we’ll go back to our folder that is holding all our Sprites for the Triple Shot Powerup. Click on the first one, then Shift-Click the last sprite to select all the Sprites in between.

Then click and drag those sprites into the Animation window — tadaa! Your first 2D animation!

If the animation is too fast or slow, you can tweak the speed of the animation by changing the Sample Rate on the left side. Lower values will slow the animation, higher values will speed it up.

Dragging the appropriate sprites into the Animation Window!

And the newly animated sprite in action:

The game looks much more alive now!

Creating the Speed animation

Creating the Speed Boost Powerup animation will be just the same! But this time we’ll do it a little differently — by editing a Prefab in the Hierarchy.

Drag the Prefab into the Hierarchy, and create the Animation file:

Select the object to animate, CREATE the animation file, drag in Sprites

Because this Prefab is in the Hierarchy, and not opened in the Project window (as such with the Triple Shot), we have to apply an Override to this Prefab.

This will make the change to the Original Speed Powerup Prefab. If we do not override these changes, then the animation would only be created on this particular instance of the Prefab in the current Hierarchy.

Very important to know to Override when you make changes to Prefabs within the Scene Hierarchy.

Prefab Override

And that’s that! Animating 2D Sprites thankfully isn’t that complex thanks to Unity’s Animation System!

Look at those Sprites sparkle!

Next we’ll look at creating and animating a Shield Powerup for our Player!

Audio Engineer turned Unity Game Dev. Will be combining both my skillsets when appropriate, and will be documenting my Unity Dev growth in these Medium Articles