Animating in Unity

This short course will teach you the basics of creating an animated sprite that you can use in a Unity 2D video game.

Start a new project in Unity. Make sure that you've selected the 2D Format.

Tut1.png

Next, import your spritesheet. It's important that you use a spritesheet with a transparent background to save you time in a moment. I've included a sample spritesheet that you can use for this tutorial.

Tut2.png


Tut3.png


UnityAnimationTutorialSpritesheet.png

Select the spritesheet from the Assets folder in the Project panel, then go to the inspector. Change the Sprite Mode to "Multiple," then enter the "Sprite Editor."

Tut4.png

We're going to use the "Slice" function in the Sprite Editor to cut out each frame of our animation and turn it into its own image. To do this, simply click on "Slice" in the upper lefthand corner of the editor. Make sure your settings are the same as those shown in the second image, and then click "Slice" in the popup window.

Tut5.png


Tut6.png

Now each frame of the animation is highlighted in its own box. If you click on each box, you can adjust it to better fit each image. Once you're satisfied, click "Apply" to save your images, then exit the editor

Tut7.png

Select the first frame of your animation and drag it out into your scene.

Tut8.png

With your new object selected, click "Add Component," select "Miscellaneous," and select "Animator."

Tut10.png

Next, create a new animation by selecting "Assets," then "Create," then "Animation."

Tut9.png

Open the Animator panel, and drag your newly-created animation from the project panel to the Animator panel.

Tut11.png

Now select the Animation panel. Select all of the frames of your animation, and drag them onto the first line of the Animation panel. Now if you click the Play button at the top of the screen, your character will walk for one cycle!

Tut12.png

If you select your new animation from the Project panel, then go to the Inspector panel, you can check the box for "Loop Time," which will make your character walk in a constant loop whenever you press "Play."

Tut13.png

Click here to see the final result!

Return to top