Simple Guide to Animating Sprites in Unity

Objective: attach an explosion animation to an empty game object.

Select an object in the Hierarchy to which you wish to attach an animation. This can be anything. In this short article, I will create an empty game object and attach an explosion animation.

In the Hierarchy window, select Create Empty, rename the GameObject to Explosion, and finally reset its Transform Position to (0,0,0).

Let’s create an empty game object to hold our explosion animation.

Select WindowAnimationAnimation. This opens up the Animation window; dock it next to your Console.

Create a new Folder in the Assets. Name this folder “Animations”.

Organize your work - send all your animations in a unique folder.

You will see the message in the Animation window which states: “To begin animating Explosion (name of object selected from the hierarchy), create an Animator and an Animation Clip” with a “Create” button underneath. Click on “Create”, select the Animations folder, and save your animation as Explosion_anim.

This will give you a dope sheet. Make sure that the object (Explosion) is selected in the Hierarchy, and press the record button. The time scale will turn red, letting you know you are in record mode. While in record mode, go into your folder which holds the sprite animation sheets you selected, click and drag the list of sprite sheets into the dope sheet of the Animation window. These animation sheets will automatically be applied to the dope sheet, and if you select the play button, you will be able to observe the animation in the Scene window in real-time.

Watch your animation sequence in real-time in the Scene window.
Newly created Animation file and animation controller.

If you are happy with the animation, deselect the record button. This will leave you with two files in the Animations folder: the Explosion_anim that you just created and the Explosion animation controller. This controller is what controls the logic for playing back the animation.

Keep the ‘Loop Time” checked if you wish your animation to continuously play.

By default, the animation will be set to loop continuously. If you don’t want it to loop, select the animator file in the project window, and deselect the “Loop Time” box.

Animator component added by default.

If you then select the object that you animated in the Hierarchy, Unity will add by default an Animator component with the associated animation controller already attached. In our case, the controller is named Explosion.

There you have it. A quick and simple reference to animating sprites in Unity. Hope it helps.

Very nice!