How To Animate A 2D Object In Unity

Many indie developers, hobbyist programmers, and professionals want to know how to animate a 2D object in Unity. Whether you’re making a platform game, puzzle game, or shooting game, adding animation to your 2D designs can make them more engaging. It can help players have more fun in the game and help them understand the story better.

In this article, we’ll cover some of the basics of 2D animation, teach you how to set up your workspace in Unity, and show you some simple animation techniques so you can create 2D animations without writing any code.

How To Animat‌e In 2D Unity

Before using the animation tool, it is important to prepare your assets or files properly. In this section, we will show you how to import and setup sprites to do 2D animation in Unity.

  1. Importing sprites

  • Unity supports many image formats for 2D graphics. Such as PNG or PSD files.

  • Keep the following points in mind when importing sprites

  • Set the Texture Type option to “Sprite (2D and UI)”

  • If you are using a sprite sheet that has multiple sprites, select “Multiple” in Sprite Mode and cut the sprites with the Sprite Editor

It is better if the sprite has transparency because it makes it easier to create layers

  1. Setting up the animator

  • To animate any object, you need to add an Animator Component to it. It works with the Animator Controller which controls various animation states such as standing, walking or jumping.

  • First, create a new Animator Controller and attach it to your 2D object. You can then control how the object’s animation will play out.

Learn Unity 2D Animation Object Easily

Before learning how to animate a 2D object in Unity, you need to have your images or sprites properly prepared. In this part, we will learn how to create 2D animation in Unity.

1. How to use the Animation Window

Unity’s Animation Window is where you will create animations. Here you can animate:

  • Position
  • Rotation
  • Size or Scale
  • Sprite Change
  • Color or Opacity

First open the Animation Window. Select your object. Then click on “Create New Clip”. Now the things you change will be recorded on the timeline.

2. Timeline and Keyframes

Animation in Unity is done with Keyframes. Keyframes are the points where something changes (such as changing position or images). Unity itself smooths the movement in the rest of the time.

Example:

  • Coin jumping
  • Character standing
  • Fire burning
  • UI appearing or disappearing

3. Using the Animator Controller

With the Animator Controller, you decide which animation will run.

Example:

  • Idle (character standing)
  • Walk (character walking)
  • Jump (character jumping)

There is a separate animation clip for each state. You can decide which animation will run by setting conditions.

Frame-by-frame 2d object animation (with Sprite Sheet)

A Sprite Sheet means having many images together. You can create movement by showing images one by one.

Steps:

  • Cut the image with Sprite Editor
  • Bring all the images to the Animation Window
  • Unity will create the animation automatically
  • Increase or decrease the frame rate to adjust the speed

This way you can easily create characters, water, fire or small movements.

Some tips for good animation

1. Organize your files

Keep Sprites, Animation, and Controller in separate folders

2. Name them clearly

Example: Player_Idle, Coin_Spin – this will make it easier to find

3. Don’t put too many transitions together

Putting too many things together unnecessarily can slow down the game

4. Always test by running it in the game

See how the animation looks in the game according to the camera, lighting or scaling

Ways to make animation better

1. Use layers

You can animate the character’s arms and legs separately

2. Use Blend Tree

The walking animation will run smoothly according to the speed

3. You can use Animation Event

To play a sound or show something at a specific time

Why is it necessary to learn Unity 2D animation?

Learning animation in Unity will make your game look much more beautiful and alive. Even small animations make the game interesting.

For example:

  • Clouds floating
  • Characters breathing
  • UI coming or going

Unity’s 2D tools are very easy to use. No need to know code. Artists or designers can also work easily.

Last but not least

Learning how to animate a 2D object in Unity is not difficult. If you understand the basics, you can take your game to a whole new level with animation.

In this guide, you learned:

  • Importing sprites
  • Using the Animation Window
  • Creating transitions in the Animator Controller

Now you can make your animation more beautiful and professional by using Layers, Blend Trees, and Events.

With these tools in Unity, you can make your 2D game more interesting and fun.

unity 2d animation youtube

DOWNLOAD THE ANIMATION FILE

Adding smooth animations when you press a button will make your game look more beautiful and responsive. If you want to add animated effects to your UI (buttons or menus), this Unity Anim‍at‌ion B‌ut‍ton Click will teach you how to activate animations when you press a button.