Animating 2D Sprites In Unity

Samantha Gittemeier
4 min readMay 24, 2023

--

Animations are an amazing way to really get your game looking polished and professional. I can’t think of any game that doesn’t have some sort of animation, it’s how you give your game movement. Imagine playing a game and your character and environment is entirely stiff, and then when you use a control to move, it’s just blocky and jumpy. That wouldn’t look great.

But when you add in the animations, you get something more appealing, more visually stimulating, and polished. Even if it’s on something that sits still, it should have some sort of movement to it.

In this article we will talk a bit about how to animate in 2D by using the Unity Animation system to animate some 2D Sprites.

Creating The Animation

First you need to select the game object that you want to have the animation on. With that object selected, click on the Window tab at the top, hover over the Animation option, then select Animation. A new Animation window will open. You can dock it next to your console window by dragging it down next to your console tab.

Now before you create your animation, just to stay organized, I’d suggest creating an Animations folder in your Assets folder. Then we will click on Create in our Animation tab. For this example I will be animating my Triple Shot Powerup in my 2D Space Shooter. So I’m going to name it TripleShotPowerup_A or _Anim if you’d prefer, this will make it easier to navigate in the future to find exactly what we are looking for.

This will also automatically create our animation and our controller for us in our Animations folder. Now we have just created our animation.

Adding The Frames

Next up we are going to add our frames into our animation. For this we can simply click on the object we are animating, hit the record button in our animation tab, and then drag the frames of our animated sprite into our animation window. We can select all of the frames by simply clicking the first frame, holding down the Shift key, and selecting the last frame, and then dragging them over.

Now we have our frames in our animation. Now if you want to preview the animation you can hit the play button and watch it in real-time. (Trigger Warning: Colors change quickly, be aware in case of photosensitive epilepsy)

Now we have created our animation clip

Looping By Default And How To Change It

Now we can look into the settings of our animation by double-clicking our controller component for our animation from inside our Animations folder.

And by default, we can see that the animation loops. If I were to change my triple shot speed to 0 so it stays still, and play my game, we can see in the controller that the animation just loops. (Warning: though the powerup is small in this next clip, it does still change quickly)

However, if we do not want our animation to loop we can simply change this in the animation clip itself. In the Inspector panel, if we select our Animation clip from our Animations folder, there is an option labeled Loop Time that we can check and uncheck. Unchecking this option will make it so that the animation will only play once.

Now that you’ve got an introduction to animating 2D Sprites in your Unity project!

--

--