DEV Community 👩‍💻👨‍💻

May Do
May Do

Posted on

Unity 2d Animation Creating a 2D animation with Unity

Unity makes creating animations very easy with a simple drag and drop method. To create a 2D animation in Unity, you first need some art assets that has each frames of a movement. There are many assets online for free. You can even find some on Unity Asset Store or itch.io. For this project, I will be using the 1bit pack from Kenney's assets. If your sprite sheet came with more things attached to it than you need, you can go ahead and crop out the image file as an easy fix so that there are only the sprite items we are going to use. The sprites that I am using looks like this:
Alt Text

Once you have the sprite sheets ready, import it into Unity and click on the image file. The inspector tab should be open to that selected image file. In the inspector tab, go to Sprite Mode. The default settings should be Single. Click the drop down menu and change that to Multiple so that the image is splitting each section into multiple items. This means that the image is no longer holding one item but many so that it can loop over each item to play the animation. Click Apply at the bottom and then Sprite Editor below Sprite Mode.
Alt Text
Alt Text

When the Sprite Editor is open, slice the image. Each item should then be clickable and customizable. The slice should be a prompt at the top of the window that looks something like this:
Alt Text

After you close the sprite editor, grab the sprite and simply place it in the Scene tab. You could also create a new animation through the Animation This should prompt a new window that asks you to create a new animation.
Alt Text
Alt Text
And that's all! Hit the play button and see your sprite animation. If you take a look at the inspector tab, you should be able to see Sprite in Sprite Renderer changing. You can further edit the animations in the inspector tab, too. Since the sprites that I used were very small I had to expand the size so the final product looks a bit blurry. The final animation for this project looks like this:
Alt Text

Note that this is only a simple cover of animation in Unity and does not go over player movement animation. If you want to create movement animation, you could create an animation and attach it to the object as a component along with some changes in code depending on how you want to animate your objects in your c# script files of your object. To learn more about animating in Unity, there is more information in Unity's documentations and Unity also offers a lot of tutorials in Unity Learn

Top comments (1)

Collapse
 
lucasosuza profile image
Lucas Souza

Hey, really nice tutorial! I have a small question: how do I remove the blur from the animation? I'm fighting with the camera...

Take a look at this:

Settings

Go to your customization settings to nudge your home feed to show content more relevant to your developer experience level. 🛠