Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
New Animation Clip Creation
3.
Adding another Animation Clip
3.1.
How it all works together
4.
Frequently Asked Questions
4.1.
What is an animator in Unity?
4.2.
What is an Animator's job?
4.3.
How do we run animations in Unity?
4.4.
What is the difference between animators in Unity and animation?
4.5.
What software do animators use?
5.
Conclusion
Last Updated: Mar 27, 2024
Medium

Creating animations in Unity

Master Python: Predicting weather forecasts
Speaker
Ashwin Goyal
Product Manager @

Introduction

In this blog, we will learn to create animations in Unity. Unity features a powerful and intuitive animation engine that allows you to animate whatever you want. However, some animations, particularly the simplest ones, do not require the entire capacity of the animation engine.

Source: https://miro.medium.com/max/1400/1*GF6nnLDjUJl6CpwkScKcBw.gif

 

Now, let us see how to create a new Animation clip in Unity.

New Animation Clip Creation

Let's learn to create a new animation clip. 

  • At first, we need to select a GameObject in our Scene
  • After that, open the Animation Window to create a new Animation Clip (top menu:) animation> Window > Animation
  • The "Create" button displays in the Animation Window timeline section if the GameObject does not currently have any Animation Clips allocated.
  • Choose the Create option. Unity suggests that you save your new empty Animation Clip to your Assets folder.
     

 Source: https://learn.unity.com/tutorial/creating-keyframed-animation-in-timeline-2019-3#

 

Unity performs the following actions when you save this new empty Animation Clip:

  • This function generates a new Animator Controller Asset.
  • Adds the new clip as the default state to the Animator Controller.
  • Adds an Animator Component to the GameObject to which animation is being applied.
  • The new Animator Controller is assigned to the Animator Component.
  • The animation system's required elements are now in place, and you can begin animating the GameObject.

 

Now, let’s learn how to add another animation clip using Unity.

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Adding another Animation Clip

If the GameObject already has one or more than one animation clips assigned, the "Create" button is hidden. One of the existing clips will be visible in the Animation window instead of the "Create" button. To switch between Animation Clips, we will use the menu in the top-left corner of the Animation window, next to the playback controls.

Select Create New Clip from this menu to add a new Animation Clip to an existing GameObject. Again, Unity prompts us to save our new empty Animation Clip before you can work on it.

Source: https://docs.unity3d.com/Manual/UnityOverview.html

How it all works together

The preceding steps automatically create the necessary components and references. It is, however, useful to understand how the pieces fit together.

  • An Animator component is required for a GameObject.
  • An Animator Controller Asset must be assigned to the Animator component.
  • One or more Animation Clips must be assigned to the Animator Controller asset.
  • The diagram given below shows how Unity assigns these pieces, starting with the new Animation Clip in the Animation Window.

Source: https://docs.unity3d.com/uploads/Main/AnimationNewClipAutoSetup.png

 

After we create a new Animation Clip, we can now see:

  • The Animation Window (top left) displays a timeline with a white playback headline, ready for new keyframes to be recorded. The clip's name appears in the clip menu, just below the playback controls.
  • The Inspector (center) reveals that the "Cube" GameObject has an Animator Component. The Controller field of the component reveals that it is assigned to an Animator Controller Asset called Cube.
  • The Project Window (bottom right) displays two new Assets: an Animation Clip Asset called Cube Animation Clip and an Animator Controller asset called Cube.
  • The Animator Window (bottom left) displays the Animator Controller's contents: The controller has a Cube Animation Clip in the default state. Subsequent clips added to the controller are grey, indicating that they are not in the default state.

 

Source: https://docs.unity3d.com/uploads/Main/AnimationEditorNewAnimationAdded.png
 

Now, we will move to the Faqs section to clear our doubts regarding creating animations.

Frequently Asked Questions

What is an animator in Unity?

An Animator Controller allows us to arrange and maintain a set of Animation Clips and associated Animation Transitions. Transitions define how long a blend between states should take and the conditions that activate them.

What is an Animator's job?

An animator's job is to create a series of images called frames. When frames are combined, they create the appearance of the movement known as animation. They use digital or hand-drawn graphics, models, or puppets to create the images. Animators specialize in 2D, 3D modeling, stop-frame animation, and computer-generated animation.

How do we run animations in Unity?

First, we need to choose our animation clips. After choosing the animator clip, we need to create an Animation Controller. To animate a player or game object, attach this controller to it. In the end, select an animator from the Windows menu. Two states will be formed if you drag the two animation clips to the Animator window.

What is the difference between animators in Unity and animation?

Animations are older versions of Animators. Animators were introduced in version 3.0 to help overcome some of the animation's shortcomings. Animations only change the visual representation of the object. Animations are recommended to use when we are just changing the opacity. But it causes problems when we want to rotate, translate or scale objects.

What software do animators use?

Autodesk Maya is the software for many animation studios and professional animators. Character development, simulation, modeling, motion graphics, and more are all possible with this 3D animation software.

Conclusion

In this article, we have extensively discussed creating animations in Unity. This article outlines how to create new animations and add another animation. And at the end of the blog, we have seen some faqs to understand Animation creation in Unity better. 

After reading about the creating animations in Unity, are you not feeling excited to read/explore more articles on the topic of Unity? Don't worry; Coding Ninjas has you covered. To learn, see Unity ConsoleElements of UnityParticle System in Unity, and Rigidbody in Unity.

Refer to our Guided Path on Coding Ninjas Studio to upskill yourself in Data Structures and AlgorithmsCompetitive ProgrammingJavaScriptSystem Design, and many more! If you want to test your competency in coding, you may check out the mock test series and participate in the contests hosted on Coding Ninjas Studio! But if you have just started your learning process and are looking for questions asked by tech giants like Amazon, Microsoft, Uber, etc; you must look at the problemsinterview experiences, and interview bundle for placement preparations.

Nevertheless, you may consider our paid courses to give your career an edge over others!

Do upvote our blogs if you find them helpful and engaging!

Happy Learning!

Previous article
Animation and Animator in Unity 3D
Next article
Moving RigidBody
Live masterclass