Animating Sprites in Unity

Bob Hilbig
3 min readOct 4, 2021

I’m no artist.

Cool guys don’t look at explosions.

I appreciate artists though.
Let’s talk about animating our 2d game. We’ve got exploding enemies, powerups and shields so far in our game. We’ve already animated some of those. How are they done? And what does a 2d sprite animation look like in the first place?

Many frames. Handle it!

First, the setup. An artist has given us a bunch of frames, much like an analog film. There will be multiple frames of a ship going from intact, to firey explosion, to empty sparse debris field.

How do you create? Click create!

Next let’s open our prefab. Then open the animation window (default ctrl + 6) with our prefab selected. We’ll wee a window asking us to create an animation. Click create. That will open a dialog window to save the animation somewhere useful (I hope).

16 Frames of 2d Goodness.

Then we can highlight all of our frames and drag them into the Animation window.

Almost done!

When we created our Animation, that also created an animator controller by default. Normally it should name it roughly the same name as the animation. We need to place that controller onto our sprite.

Orange is Default.

The final bit of button clicking happens in the Animator window. Window -> Animation -> Animator. We should see a window with an orange field. This is our default state. Suffice to say that this is where the animation gets called and Unity assumes you want to call it right away. For the case of powerups, this is indeed the case. In another article we’ll go into more detail on this screen, and coding for animations.

Meanwhile, click on the orange field and look at the inspector. There are a few parameters you may want to tweak here, but maybe the one that is easiest to try is the speed. Default is 1.

Next lets click on the animation clip. Make sure Loop Time is checked in the inspector. This will allow the animation to repeat endlessly.

Now when the game is played, our powerup will animate properly! Huzzah!

--

--