Unity Basics: Animator — Part 1

Everything About Animation Clips

--

What Is an Animator?

The Animator is a core component of Unity’s animation system, known as Mecanim. According to Unity’s documentation, the Mecanim system provides the following features:

  • Easy animation setup for all elements in Unity, including objects, characters, properties, and more.
  • Support for both, imported animation clips and animations created within Unity.
  • Humanoid animation retargeting.
  • Applying animations from one character model to another.
  • Simplified workflow for adjusting the position of animation clips.
  • Convenient previews of animation clips, transitions, and interactions. This allows animators to work more independently from programmers, creating prototypes and previewing animations without waiting for game code implementation.
  • Managing complex interactions between animations using visual programming tools.
  • Animating different body parts with separate logic.
  • Layering and LayerMasks

As you can see, the Mecanim animation system offers many different features. In this post, we are going to talk about the most basic usage and about animation clips.

There is also an older animation system called Legacy, but we will not cover it in this post.

How to Use Animator?

In order to use the Animator, you need to have the following 3 things in place:

  • A GameObject that will be the subject of the animation.
  • An Animation Clip that you want to run/execute.
  • An Animator Controller that contains various animation states and transition information.

Once you have everything you need, you can use the following steps to animate specific game objects:

  1. Create an Animator Controller via right-click in the Project View
  2. Create an Animation Clip by right-clicking in the Project View.
  3. Double-click the Animator Controller you wish to edit.
  4. Drag and drop the Animation Clip you want to execute into the Animator View.
  5. Add the Animator Component to a specific GameObject placed in the scene.
  6. Connect the Animator Controller created in step 1 to the Animator Component
  7. Launch your game

If you’ve followed along up to this point, a specific game object should now be in a state where it’s playing the animation clip you just added. However, because it’s an empty animation clip with no information, nothing actually happens.
Next, let’s look at how to edit this animation clip.

How to edit Animation Clips?

To edit an animation clip, you need to open the Animation view. Here’s how to open it:

  • Double-click an animation clip to open it
  • Open via Window → Animation → Animation
How to Open the Animation View

When you open the Animation view using the method above, you should see something like the screen below.

Animation View

The Animation view can be broadly divided into the Properties area on the left and the Timeline area on the right.

✅ What is a Property Area?

The property area is a list of properties for the game object controlled by the animation clip and its child game objects’ components. All properties that you want to control through an Animation Clip must be added to that list.

Properties can be added to this list by clicking the “Add Property” button at the bottom of the area/list. You can also add them through recording, which we will discuss later.

Example of Adding Animation Properties

To add properties to an animation clip, the GameObject that the animation clip is used on must be selected.

Also, the only properties that can be added are those contained in the GameObject and its child object. (You cannot add properties from the parent game object.)

✅ What is a Timeline Area?

A Timeline Area is an area where you can edit added properties in detail, specifying what values they should have at a particular point in time. In Unity, this area is referred to as a keyframe, and you can add Keys to specify the values of properties for each keyframe.

Let’s create a simple animation adjusting the Transform, including how to add keys for each property and how to preview the animation.

Example of Editing Animation Timeline Area

As you can see in the video above, if there are empty Key Frames between two Keys, the property values change naturally by interpolating between the two Keys. In other words, you don’t need to add Keys to every Keyframe.

You can zoom in and out of the Timeline Area using the mouse wheel.

*Interpolation refers to estimating a value between given values based on those given values.

✅ What is a Recorder?

The Recorder in Unity allows you to change the value of any component at a specific Keyframe (without adding any properties or keys), and this information is recorded in the animation clip.
It may be difficult to understand just by reading, so let’s watch this clip to see how it works.

Example of using the Recorder

Recorder is a very handy feature but should be used cautiously during testing. If you modify the values of other components while the recording feature is enabled, unintended records may be captured.

Additionally, the recorder cannot be used for humanoid-type character animations.

✅ How can you modify the automatically interpolated values?

As mentioned earlier, Unity automatically interpolates between two Key values if there is a gap. This allows you to work comfortably without having to add Keys to every Keyframe. However, you may not want such interpolation or you may want to change how the interpolation is done.

If you look at the bottom of the properties area of the animation view, you will see tabs called Dopesheet and Curves. The method of adding and modifying keys explained above is the Dopesheet method, and if you select Curves, you can see how the interpolation is done.

In Unity, curves are commonly represented using Bezier curves, and you can set the slope of the curve by selecting the key displayed in the timeline area. You can also change the curve’s setting by right-clicking.

Let’s check out how editing this curve affects the animation through a video below.

Example of Editing Animation Curves

Unity’s curve editing is not only used in the animation clip above, but in many other systems in the same way. If you want to learn more about this, click here.

If you want to see multiple selected keys on one screen, simply choose the desired keys -> press the “F” key on your keyboard, and the zoom level and position will be automatically adjusted to display the selected Keys.

✅ How to change an Animation Clip?

In the Animator Controller, you can add various animation clips. If you want to test different animation clips on a character that has a specific Animator Controller applied, then select the game object where the animation is running and change the animation clip using the dropdown at the top of the Properties area in the Animation View.

Example of Changing Animation Clips

However, you must select a GameObject that is using the corresponding Animator Controller to change or preview an Animation Clip.

Also, only Animation Clips that have been added to the Animator Controller will be displayed in the dropdown.

✅ What is an Animation Event?

While developing a game, you may want to know when a specific animation reaches a certain frame. There are various ways to check this timing, one of which is an Animation Event.

You can add an Animation Event by selecting the desired keyframe and clicking the “Add Animation Event” button or right-clicking just below the keyframe tick mark.

Example of Adding Animation Events

Animation Events can call public functions of components that are on the game object with the Animator component containing the animation clip. It’s important to note that this method can have a maximum of one parameter, and the parameter type must be one of the following:

  • int
  • float
  • string
  • Object
Example of Animation Event Integration

However, keep in mind that if the animation skips or ends without executing that part, the skipped frame’s animation event will not be executed.

Conclusion

Today, we looked at how to create and modify animation clips in Unity, a crucial element in game development. Animators are essential not only for 3D characters but also for various situations such as 2D characters and UI elements, making them a crucial element in the game development process.

However, covering all aspects of the Animator in a single post is challenging, so we have divided it into two parts. In the second part, we will focus on editing the Animator Controller in detail.

Hopefully, this post has been helpful not only for those who are new to Animator but also for those who are already familiar with it.

<Related Posts>

Want more hyper-casual game development tips?
Click here and Become Our Partner today!

[Contact]
- E-mail: help@supercent.io
- Website:
en.supercent.io

--

--

Supercent.official
Supercent Blog 슈퍼센트 블로그

Insights and tips to take your hyper-casual game to the top of the charts