Version: 2017.2
动画
动画剪辑

动画系统概述

Unity 有一个丰富而复杂的动画系统(有时称为“Mecanim”)。该系统具有以下功能:

  • 为 Unity 的所有元素(包括对象、角色和属性)提供简单工作流程和动画设置。
  • Support for imported animation clips and animation created within Unity
  • 人形动画重定向 - 能够将动画从一个角色模型应用到另一角色模型。
  • 对齐动画剪辑的简化工作流程。
  • 方便预览动画剪辑以及它们之间的过渡和交互。因此,动画师与工程师之间的工作更加独立,使动画师能够在挂入游戏代码之前为动画构建原型并进行预览。
  • 提供可视化编程工具来管理动画之间的复杂交互。
  • 以不同逻辑对不同身体部位进行动画化。
  • 分层和遮罩功能
Typical view of an Animation State Machine in the Animator window
Typical view of an Animation State Machine in the Animator window

动画工作流程

Unity’s animation system is based on the concept of Animation Clips, which contain information about how certain objects should change their position, rotation, or other properties over time. Each clip can be thought of as a single linear recording. Animation clips from external sources are created by artists or animators with 3rd party tools such as Max or Maya, or come from motion capture studios or other sources.

Animation Clips are then organised into a structured flowchart-like system called an Animator Controller. The Animator Controller acts as a “State Machine” which keeps track of which clip should currently be playing, and when the animations should change or blend together.

一个非常简单的 Animator Controller 可能只包含一个或两个剪辑,例如,使用此剪辑来控制能量块旋转和弹跳,或设置正确时间开门和关门的动画。一个更高级的 Animator Controller 可包含用于主角所有动作的几十段人形动画,并可能同时在多个剪辑之间进行混合,从而当玩家在场景中移动时提供流畅的动作。

Unity’s Animation system also has numerous special features for handling humanoid characters which give you the ability to retarget humanoid animation from any source (Eg. motion capture, the asset store, or some other third-party animation library) to your own character model, as well as adjusting muscle definitions. These special features are enabled by Unity’s Avatar system, where humanoid characters are mapped to a common internal format.

Each of these pieces - the Animation Clips, the Animator Controller, and the Avatar, are brought together on a GameObject via the Animator Component. This component has a reference to an Animator Controller, and (if required) the Avatar for this model. The Animator Controller, in turn, contains the references to the Animation Clips it uses.

此图显示了动画系统的各个部分如何连接在一起
此图显示了动画系统的各个部分如何连接在一起

上图显示了以下内容:

  1. Animation clips are imported from an external source or created within Unity. In this example, they are imported motion captured humanoid animations. 2.动画剪辑显示并排列在Animator Controller中。因此,在 Animator 窗口中会显示Animator Controller的视图。状态(可表示动画或嵌套的子状态机)显示为通过线条连接的节点。此Animator Controller作为资源存在于 Project 窗口中。 3.骨架角色模型(在本示例中为宇航员“Astrella”)具有映射到 Unity 常见替身格式骨骼的特定配置。此映射作为导入的角色模型的一部分存储为 Avatar 资源,并且在 Project 窗口中显示(如图所示)。
  2. When animating the character model, it has an Animator component attached. In the Inspector view shown above, you can see the Animator Component which has both the Animator Controller and the Avatar assigned. The animator uses these together to animate the model. The Avatar reference is only necessary when animating a humanoid character. For other types of animation, only an Animator Controller is required.

Unity’s animation system (Known as “Mecanim”) comes with a lot of concepts and terminology. If at any point, you need to find out what something means, go to our Animation Glossary.

旧版动画系统

虽然在大多数情况下建议使用 Mecanim,但是 Unity 保留了 Unity 4 之前的版本便存在的旧版动画系统。在处理 Unity 4 之前的版本创建的旧内容时可能需要使用它。有关旧版动画系统的信息,请参阅此部分

Unity 致力于将工作流程合并到 Mecanim 中,从而逐步彻底淘汰旧版动画系统。

动画
动画剪辑