Version: 2017.1
动画过渡
Human Template files

Avatar Mask

通过遮罩功能可以丢弃剪辑中的一些动画数据,从而让剪辑仅动画化对象或角色的某些部分而不是整体。例如,可能有一个标准的行走动画,其中包括手臂和腿部运动,但如果一个角色用双手抱着大型物体,那么不会希望其手臂在行走时向侧面摆动。但是,仍然可以在角色抱着物体时使用标准行走动画,但需要使用遮罩在行走动画的上层仅播放抱着物体动画的上半身部分。

Masking can be applied to animation clips either during import time, or at runtime. Masking during import time is preferable, because it allows the discarded animation data to be omitted from your build, making filesize and memory footprint smaller. It also makes for faster processing speed because there is less animation data to be blended at runtime. In some cases, import masking may not be suitable for your purposes, in which case you can apply a mask at runtime by creating an Avatar Mask asset, and using it in the layer settings of your Animator Controller. This page relates to creating an Avatar Mask asset.

There are two ways to define which parts of your animation should be masked. If your animation uses a Humanoid avatar, you have the option of using the humanoid body selection method which allows you to click on a simplified diagram of a humanoid body to select or deselect certain parts to mask.

The body parts included are: Head, Left Arm, Right Arm, Left Hand, Right Hand, Left Leg, Right Leg and Root (which is denoted by the “shadow” under the feet). In the body mask, you can also toggle inverse kinematics (IK) for hands and feet, which will determine whether or not IK curves will be included in animation blending.

  • Click the avatar section to toggle inclusion or exclusion (green/red)
  • Double click in empty space surrounding the avatar to toggle all
Defining an avatar mask using the humanoid body selection method
Defining an avatar mask using the humanoid body selection method

Alternatively, if your animation does not use a Humanoid avatar, or if you want more detailed control over which individual bones are masked off, you can use the Transform method to select or deselect portions of the model’s hierarchy to mask. To do this, you must assign a reference to the avatar whose transform you would like to mask off, then click the “Import Skeleton” button. You will then see the hierarchy of the avatar listed in the inspector. Each bone has a checkbox allowing you to select or deselect parts of the hierarchy to use as your mask.

使用 Transform 方法定义 Avatar 遮罩
使用 Transform 方法定义 Avatar 遮罩

当指定动画层在运行时应用遮罩,或者在动画文件的导入设置中将遮罩应用于导入动画时,可在 Animator Controller 中使用遮罩资源。

使用遮罩的好处在于有助于减少内存开销,因为非活动身体部位不需要关联的动画曲线。此外,在播放期间不需要计算未使用的曲线,因此还有助于减少动画的 CPU 开销。

动画过渡
Human Template files
Copyright © 2020 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961