Simple sprite animation in Unity

The space shooter is starting to feel like an actual game with the addition of power-ups but it looks a bit stiff. I will show you how to add a simple animation to the power-up.

Start by opening the Animation window:

You can dock this window. I have mine together with the Game and Console window:

Select the power-up in the hierarchy. In the Animation window you now have the option to create a new animation. Click on Create and save the new animation file:

Select all the sprites for the power-up and drag into the Animation window:

On the power object you will now have a new component called Animator. On the Animator component there is now a Controller attached, which has the same name as the game object:

If you double click on the controller you will open up the Animator window for this object. The Animator handles the logic for the selected objects animation. Currently, there is only one animation on this object to which it defaults to. The following animation is the one that has just been created:

In the Project window you can see that the controller has been added to the same location as the animation file:

If you start the game now you can see that the animation is already working:

Good luck!

Unity / C# Game developer