Animating Sprites | Unity Developer

Derek Anderson
3 min readMay 30, 2023

--

Our space shooter game is coming along nicely, and it’s about time that we dive into animating sprites in Unity. We’ll begin with animating our triple shot powerup. Begin by selecting the GameObject to animate, which is the triple shot powerup in this case. Once you’ve done that, open the Animation window in the Window dropdown menu in Unity. Drag this animation window over by the Game and Console windows in the lower left.

Create a new animation in the Animation window. Create a new folder called Animations that will store all of the animations that we’ll create for our game. Save our animation as triple_shot_powerup.anim. Once that is saved in the Animations folder, we can begin creating keyframe animations.

Select the triple shot powerup in the Hierarchy View and click on the record button in the Animation window. It will turn red, meaning you are now recording the animation. In our Sprite folder, we have a number of sprites for our triple shot powerup underneath the powerups. Shift click all of the triple shot powerup sprites, and drag them over to the Animation window once they are selected. If we hit play in the Animation window, we can see our triple shot powerup animation in the Scene View.

Two things will happen once you stop recording the animation. In the Animations folder in our Project View, there is our triple shot powerup animation and a controller for the animation. The controller controls the logic for the animation. This will be useful in more complex animations, such as a character attack combo. The GameObject will also have an Animator component added to it by default in Unity, with the controller attached to it. Clicking on the controller will bring up an Animator Window.

There is our animation clip and an entry state in the Animator Window. When we run this in Unity, our animation will automatically loop by default. You can see this in action if you were to temporarily set the speed of the powerup to 0. Not only will our animation play out in the Scene View, we can see it looping in the Animator window.

--

--