Sprite Animations in Unity

Sometimes having just a static image for your player, or any other object for that matter is not the best experience.
Movement is often crucial for making things come to life.

There are a few ways you can approach animating sprites in Unity.
If you already have a range of sprites, the easiest way is to select them all and drag them into the hierarchy.
This will pop up a file dialog where you give a name for the animation and select where to store it. Once that’s done you’ll have a default animation for that newly created gameobject.

You can also select a gameobject and in the animation window click the Create button. Give it a name and select where to store it.

Then you can drag one by one, or all of them at once into the animation keyframe window.

Once all the sprites are there you can hit the Play-button to take a look at how the animation looks.

By adjusting the Samples number you can change the speed of the animation. If you don’t see that field, click the three small dots in the upper right of the animator window and select “Show Sample Rate”.

When playing the animation you can see the white line moving along as the animation is playing. All the diamond shapes are individual sprite keyframes.
You can freely move them around if you want to create a larger space between two keyframes etc.

Whenever you have something that has an animation, it also requires an Animator component. The animator is what keeps track of the animations and any transition between them if you have more than one.
The animator controller is often unique to the gameobjects type, so you don’t need one for each spawned enemy, but you’ll most likely have different ones for various enemy types, the player, and so on.

As you can see, getting started with animating sprites is pretty straightforward. Obviously, there are more things you can do with animations and the animator, but I won’t be covering that here. I highly suggest tinkering with it!

Thank you for your time 😄



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