Version: 2021.1
Using the Animation view
Animating a GameObject

Creating a new Animation Clip

To create a new Animation ClipAnimation data that can be used for animated characters or simple animations. It is a simple “unit” piece of motion, such as (one specific instance of) “Idle”, “Walk” or “Run”. More info
See in Glossary
, select a GameObject in your Scene, and open the Animation Window (top menu:) Window > Animation > Animation.

If the GameObjectThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
See in Glossary
does not yet have any Animation Clips assigned, the “Create” button appears in the centre of the Animation Window timeline area (see Fig 1: Create a new Animation Clip).

Click the Create button. Unity prompts you to save your new empty Animation Clip in your AssetsAny media or data that can be used in your game or project. An asset may come from a file created outside of Unity, such as a 3D Model, an audio file or an image. You can also create some asset types in Unity, such as an Animator Controller, an Audio Mixer or a Render Texture. More info
See in Glossary
folder.

Fig 1: Create a new Animation Clip
Fig 1: Create a new Animation Clip

When you save this new empty Animation Clip, Unity does the following:

  • Creates a new Animator Controller Asset
  • Adds the new clip into the Animator Controller as the default state
  • Adds an Animator Component to the GameObject that you are applying animation to
  • Assigns the new Animator Controller to the Animator Component

All the required elements of the animation system are now set up, and you can begin animating the GameObject.

Adding another Animation Clip

If the GameObject already has one or more Animation Clips assigned, the “Create” button is not visible. Instead, one of the existing clips is visible in the Animation window. To switch between Animation Clips, use the menu in the top-left of the Animation window, under the playback controls (see Fig 2: Adding more Animation Clips).

To create a new Animation Clip on a GameObject that has existing animations, select Create New Clip from this menu. Again, Unity prompts you to save your new empty Animation Clip before you can work on it.

Fig 2: Adding more Animation Clips
Fig 2: Adding more Animation Clips

How it fits together

The above steps automatically set up the relevant components and references. However, it is useful to understand how the pieces connect.

  • A GameObject must have an Animator component
  • The Animator component must have an Animator ControllerControls animation through Animation Layers with Animation State Machines and Animation Blend Trees, controlled by Animation Parameters. The same Animator Controller can be referenced by multiple models with Animator components. More info
    See in Glossary
    Asset assigned
  • The Animator Controller asset must have one or more Animation Clips assigned

The diagram below shows how Unity assigns these pieces, starting from the new Animation Clip in the Animation Window (see Fig 3: Animation Clip Diagram).

Fig 3: Animation Clip Diagram.
Fig 3: Animation Clip Diagram.

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

  • The Animation Window (top left) shows a timeline with a white playback head line, ready to record new keyframesA frame that marks the start or end point of a transition in an animation. Frames in between the keyframes are called inbetweens.
    See in Glossary
    . The clip’s name is visible in the clip menu, just below the playback controls.
  • The InspectorA Unity window that displays information about the currently selected GameObject, asset or project settings, allowing you to inspect and edit the values. More info
    See in Glossary
    (center) shows that the “Cube” GameObject has an Animator ComponentA component on a model that animates that model using the Animation system. The component has a reference to an Animator Controller asset that controls the animation. More info
    See in Glossary
    , and the Controller field of the component shows that an Animator Controller Asset called Cube is assigned to it.
  • The Project WindowA window that shows the contents of your Assets folder (Project tab) More info
    See in Glossary
    (bottom right) shows that two new Assets have been created: an Animator Controller asset called Cube and an Animation Clip Asset called Cube Animation Clip.
  • The Animator WindowThe window where the Animator Controller is visualized and edited. More info
    See in Glossary
    (bottom left) shows the contents of the Animator Controller: there is a Cube Animation Clip on the controller, and that it is in the default state (as indicated by the orange color). Subsequent clips you add to the controller have a grey color, indicating they are not the default state (see Fig 4: New Animation Clip in the Project Window).
Fig 4: New Animation Clip in the Project Window
Fig 4: New Animation Clip in the Project Window

  • 2017–09–05 Page amended
Using the Animation view
Animating a GameObject
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961