Look Alive! — How to Animate Sprites in Unity

Objective: Learn how to apply simple sprite animation starting from a cropped sprite sheet

Now that we have our power up spawning and behaving as we wanted, wouldn’t it be nice to have it flicking and animating around?

We’re going to learn how to use Unity animation editor and animate sprites in a very simple way if a cropped sprite sheet is available.

A sprite sheet is just an image made of several smaller images (for example representing the frames of an animation). If you have all the parts separated into different images, using the animator will be really easy.

First let’s open the Animator window and attach it as a tab wherever we think is good, for example near the game view.

Then we create an Animations folder in our Asset folder and double click on the power up prefab. Now, in the Animation view, a Create button is visible: click it and save a new animation in the new folder. The name I chose was triple_shot_powerup_anim, appending a _anim suffix will make it easier to find it. Now select all the frames of your animation and drag them onto the Animation view.

You can see that in the Animations folder, there are now 2 files: one is the animation itself, the other is the animator which will allow animation logic handling, if needed.

If you click on the anim file and look at the inspector you will see some simple settings on default value. For example, it is set to loop… and we like it.

If you click on the animator, you will see another kind of view. It is very important to understand it. The diagram shows an entry state in green from which the object will automatically transit, according to the arrow, to our animation to stay there indefinitely, since it is a loop animation.

If you click on the states you can access to some settings and behaviour management. If you right click on a state you can elaborate a transition to other states according to some logic, but that’s material for another tutorial.

Let’s close all these views and look at the game now.

Mmm it seems I forgot to set the layer ordering for the power up!!

Let’s just put it on the same layer and order as the player.

A professional developer with passion for game developing and skill-growing. A former Nuclear Physics Researcher who changed his life to pursue his dreams

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Iterative Sorting Algorithm

Bash? Zsh? Which Shell to use in macOS Catalina

A shell catalog

Speeding up Android builds on Travis CI

Beyond 3D Podcast: The Future of Software Development, Trends in AR/VR and Collaboration

Phase 0 Portfolio Project

Linked List

Python Iterator and Generator Internals

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Daniele Quero, PhD

Daniele Quero, PhD

A professional developer with passion for game developing and skill-growing. A former Nuclear Physics Researcher who changed his life to pursue his dreams

More from Medium

Null-Safe GetComponent Call in Unity

Journal 142 — Unity Project Development, 2.5D Shooter

Creating Enemy Explosions

Audio effects for Enemies