Unity Creating an animation on an object

In this guide you will learn how to:

  • use Unity to animate a character
  • import sprites from an existing package or set of images
  • create an animation controller
  • create different animations for differnt states (e.g. idle, walking, jumping, running)
  • edit the animation state machine to transition between animation states
  • create and edit a script to change animation states

You will need to know:

You can download a sample project using the lesson media section.

This tutorial uses the asset pack Toon Characters 1 from kenney.nl

Import a sprite sheet and separate the images (use this lesson)

Create an empty game object that will be animated, in this example for the player.

Select the sprites you want to use

Drag them onto the Player game object

Save the animation with an appropriate title

Note that you have to link the animation to an object.

Open the Animation Window

Click on Window > Animation > Animation

Dock this window somewhere on your view to make it easier to access.

Don’t dock it over the game preview window otherwise you won’t be able to preview the animation.

Drag the window right to expand and show the timeline.

Click the down triangle next to Sprite to see the animation to the right

Press Play to preview your animation.

You can click and drag the keyframe sprites around the timeline to change the animation.

In the next lesson you will see how to add a second animation to an existing animation.