Unity has a rich and sophisticated animation system (sometimes referred to as ‘
Mecanim
’). It provides:
unity有一个丰富而且复杂的动画系统(有时称作"Mecnim")。它提供了:
- Easy workflow and setup of animations for all elements of Unity including objects, characters, and properties.
简单的工作流程和所有unity元素,包括物体,角色和特性的动画的创建。
- Support for imported animation clips and animation created within Unity
支持导入的动画片段和在Untiy中创建的动画。
- Humanoid animation retargeting - the ability to apply animations from one character model onto another.
人形动画重定向-把一个角色上的动画应用到另外一个上的能力。
- Simplified workflow for aligning animation clips.
简单的调整动画片段的工作流程。
- Convenient preview of animation clips, transitions and interactions between them. This allows animators to work more independently of programmers, prototype and preview their animations before gameplay code is hooked in.制作原版和预览他们的动画
对动画片段,动画间的过度和相互作用的方便的预览。它使得动画师更加独立于程序工作,在游戏运行的代码嵌入之前制作原版和预览他们的动画。
- Management of complex interactions between animations with a visual programming tool.
用一个虚拟的程序化的工具管理动画之间复杂的交互。
- Animating different body parts with different logic.
用不同的逻辑动画控制不同的身体部位。
- Layering and masking features
层和掩蔽特性
Typical view of an Animation State Machine in the Animator window
Animation workflow 动画工作流程
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.
untiy的动画系统基于动画片段的概念,动画片段包含了关于特定的物体随着时间应该如何改变它们的位置旋转和特性的信息。每一个片段可以被认为是一个单独的线性记录。从外部来源的动画片段是由艺术家或者动画师通过例如Max,Maya第三方工具,或者来自动作捕捉工作室或者其他来源创建。
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.
动画片段之后被组织成一个叫做动画控制器的类似于流程图的系统中。动画控制器扮演着状态机的角色,它记录着当前哪一个动画片段应该正在播放,和什么时候动画之间应该切换或者混合。
A very simple Animator Controller might only contain one or two clips, for example to control a powerup spinning and bouncing, or to animate a door opening and closing at the correct time. A more advanced Animator Controller might contain dozens of humanoid animations for all the main character’s actions, and might blend between multiple clips at the same time to provide a fluid motion as the player moves around the scene.
一个非常简单的动画控制器可能只包含一个或者两个动画片段,例如去控制一个powerup旋转和跳跃,或者动画控制一扇门在正确时间的开和关。一个更加高级的动画控制器可能包含几十个主要角色动作的动画,并且可能同时在多个动画之间混合以达到当玩家在场景中移动时表现出流畅的动作。
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.
Unity的动画系统也包含许多特别的特点去处理人形动画,这些特性是你能够把来自任何来源(比如:动作捕捉,asset商店,或者某个第三方的动画库)的动画重定向人形动画到你自己的模型,只要你调整肌肉定义。这些特性是有unity的阿凡达系统支持,在阿凡达系统中角色被映射到一个内部的格式。每一个上述的内容,动画片段,动画控制器,阿凡达,都是通过Animator Component组件组合。这个组件引用到了动画控制器,(如果需要)和一个这个模型的阿凡达。这个动画控制器反过来引用到了它使用的动画片段。
Diagram showing how the various parts of the animation system connect together
The above diagram shows the following:
- Animation clips are imported from an external source or created within Unity. In this example, they are imported motion captured humanoid animations.第一步:动画片段是从外部来源导入或者在unity中创建。在这个例子中,它们是动作捕捉的人形动画。
- The animation clips are placed and arranged in an Animator Controller. This shows a view of an Animator Controller in the Animator window. The States (which may represent animations or nested sub-state machines) appear as nodes connected by lines. This Animator Controller exists as an asset in the Project window.动画片断被放置和组织在动画控制器中。上图现实了一个在Animator窗口的动画控制器的视图。这些状态(节点也许表示动画或者组合的子状态机)以被线连接起来的节点出出现。这个动画控制器在项目视角中以资产的方式存在。
- The rigged character model (in this case, the astronaut “Astrella”) has a specific configuration of bones which are mapped to Unity’s common Avatarformat. This mapping is stored as an Avatar asset as part of the imported character model, and also appears in the Project window as shown.
这个角色模型有一个特定的骨骼的构造,它映射到unity常用的Avatar格式中。这个映射以阿凡达资产的方式作为这个导入的模型的一部分,并且在项目曾集中显示。 - When animating the character model, it has an Animator component attached. In the Inspector view shown above, you can see the Animator Componentwhich 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.当给一个角色模型添加动画,它需要添加一个动画控制器组件。在查看窗口中如上显示,你可以看到Animator组件同时赋予了动画控制器和阿凡达。这个animator用这些一起控制模型。只有当展示人形角色的动画时,阿凡达才需要。对于其他的动画,只需要一个动画控制器(状态机)。
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
.
unity的动画系统(被称作“Mecanim”)和许多理念和技术伴随而来。如果在任何时候你需要了解某个东西的含义,可以查阅Animation 术语。
Legacy animation system(传统的动画系统)
While Mecanim is recommended for use in most situations, Unity has retained its legacy animation system which existed before Unity 4. You may need to use when working with older content created before Unity 4. For information on the Legacy animation system, see
this section
Unity intends to phase out the Legacy animation system over time for all cases by merging the workflows into Mecanim.
尽管在大多数情况下推荐使用Mecanim,unity还是保留着它的在unity4之前的传统的动画系统,你或许在处理unity4之前的老的内容的时候用到。