Skip to main content

How to Create Animated 2D characters in Unity

· 3 min read
Brock Davis

Have you ever wondered how to create an animated character for a 2D game? I recently learned how and wanted to share the steps I took to take a sprite sheet and create it into a moving character for a 2D game in Unity.

Get a sprite sheet... whatever that is

A sprite sheet is an image that consists of several smaller images (sprites) and/or animations. The purpose of a sprite sheet is to make use of empty space in a image if you were to have a single image. We don't really need to get into the nitty gritty here. There are plenty of places to get free sprite sheets for your game. Either as a character you will use as a finish product or just a place holder so you can build and test the rest of your game. My favorite place I have found is itch.io. For this tutorial we are going to use an asset from Sunnyland created by ansimuz.

Click download now (and don't forget to contribute funds if you can to support the artist)

Import the sprite sheet

Now that we have our asset, let's import it to our project. First create a folder to put it in. I called mine images. Then in the downloaded folder, go to Sunny-land-files > Sunny-land-assets-files > PNG > spritesheets then drag player-idle to your new folder

Split and edit the sprite sheet

Now that the asset is imported, we need to make some changes so it renders properly and can be used to animate the character. When you select the image imported, the inspector will show the import settings. In that panel make the following changes:

Sprite Mode: Multiple

Pixels Per Unit: 16

Filter Mode: Point(no filter)

Compression: High Quality

Then click Apply. After that click Sprite Editor

Inside the Sprite Editor, click Slice. Set the Type to Grid By Cell Size and use the following settings:

Pixel Size: X: 32 Y: 32

Offset: X: 0 Y: 0

Padding: X: 1 Y: 0

Then click Slice and Apply. Your image will now be split into 4 images.

Now select the first image and drag it into your scene.

With the Player selected, click Window, then Animation, and then Animation.

Then click Create. MAKE SURE THE PLAYER IS SELECTED OR THE ANIMATION WILL NOT BE CONNECTED TO THE PLAYER OR OBJECT YOU ARE TRYING TO ANIMATE

Now drag the first image to the 0.00 position, the next one to 0.10, the next to 0.20, the last one to 0.30 and then the first one again to 0.40.

Now when you play the scene, your character will be animated!

Next steps

Obviously you will want to animate more than just an idle player or NPC. Next you will want to do the same with the other sprite sheets and add input to the object so you can move it. I will cover that in my next post.