When it comes to components in Unity there might be difficulty understanding the difference between two components just by looking at their names. Animation and Animator are two such components. When you start using them extensively you will get why Unity named them so. In this tutorial, we will cover the difference between Animation and Animator in Unity.
Any action related to a Gameobject is referred to as Animation and the controller used to control the actions is called Animator.
Let’s try to understand this in detail. Before that you should know the following
- A game object can have more than one animation in Unity. For example, walking, running, jumping etc.
- You need a controller to control which animation plays at what time.
Animation in Unity
Animation is also referred as Animation clip in Unity. You can create an animation or import it from other software like Blender. All Animation files are saved as a dot anim file. To create a new Animation, use the steps below
- Select the object you want to Animate in the Hierarchy.
- Go to Window>Animation>Animation or press Ctrl+6.
- In the Animation window, click create to create a new animation.
- Save it with the name of your choice. Click the record on the Animation window.
- Click on different timeline positions and move your game object to the required place.
- Click the record button again after you are done animating.
You should see this Animation clip in your project folder.
You can create multiple Animation clips for a single game object.
Animator in Unity
When you create a new Animation, Unity will attach an Animator component to your game object. This controls which Animation clip needs to play. You can do all sorts of things with the Animator. Here are a few examples
- Play Animation clips in Random.
- Slow down or speed up Animation.
- Sync audio with Animation clip using events.
- Play Animation clips when the game is paused.
Animator is a very powerful tool to control Animation clips. It is loaded with features that you can use to make your character livelier.