Create simple 2D Animation in Unity

Unity is a very powerful Game development tool and in recent years Unity has put some efforts to help developers Animate and model their game assets inside Unity. Unity 2D Animation has grown a lot. So, we thought of doing a tutorial series on Unity 2D animation. As the first part of the tutorial series let’s see how to create a simple 2D Ball bounce Animation in Unity.

I assume you know how to start a new project in Unity. For the purpose of this tutorial Lets create a new 2D project.

I am using Unity 2021.3.2 for this tutorial.

Adding Sprites to the scene

Let’s add a 2D square to the scene. Click on + sign in the hierarchy window >2D Objects>Sprites>Square.

Unity Black Friday Deals

Adjust the X and Y scale to 20 and 0.5 respectively so that it looks like a platform. Also set the color to brown.

Add a circle in a similar way and set the color to Yellow.

You don’t have to worry about the circle’s Transform as of now.

Your scene should look something like the image below.

Unity sample scene

Animating the ball

Move the Ball to the starting position.

Go to Window>Animation>Animation or Press Ctrl+6 to open the animation Window.

Select the ball in the Hierarchy window and click on the create button on the Animation window.

Blank Animation window

Give a name to the Animation clip and click save. Let’s name it Ball_bounce.

Now you should see an Animator component added to your ball Gameobject.

Click on the round red button on the left top of the Animation window to record an Animation.

After you click record, select the time on the timeline and move your ball to the new position.

Say you want the ball to hit the ground at 0.10 seconds then click on 0.10 and move the ball position to near the ground.

Animation_timeline
Ball position

Create a similar timeline event for other bounces.

Here are the settings I have used

TimelineTransform value
0:00(-9.5,1.2)
0:10(-8,-2.7)
0:20(-5,-1.1)
0:30(-2,-2.68)
0:40(0.5,0.5)
0:50(3,-2.75)
1:00(5,-2.75)

Here is the final animation

Final ball animation

You can add more Timeline points to make the animation smooth. You can also play around the ball’s scale value to make it look compresses when it hits the ground and elongated when on the top.

You can add more animation clips to the ball and play them using the Animator controller.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.