Unity 使用__动画层__来管理不同身体部位的复杂状态机。相应的示例为,您有一个用于行走/跳跃的下身层,还有一个用于投掷物体/射击的上身层。
您可以从 Animator Controller 左上角的 __Layers 小部件__管理动画层。
单击窗口右侧的齿轮可显示该层的设置。
在每一层上,您可以指定遮罩(应用动画的动画模型的一部分)以及混合类型。Override 表示将忽略其他层的信息,而 Additive 表示将在先前层之上添加动画。
可以通过按小部件上方的 + 来添加新层。
Mask 属性用于指定此层上使用的遮罩。例如,如果您只想播放模型上半身的投掷动画,同时让角色也能够行走、奔跑或站立不动,则可以在层上使用一个遮罩,从而在定义上半身部分的位置播放投掷动画,如下所示:
Layers 侧边栏中显示“M”符号,表示该层已应用遮罩。
有时,能够在不同层中复用同一状态机是很有用的。例如,如果想要模拟“受伤”行为,并生成“受伤”状态下的行走/奔跑/跳跃动画,而不是“健康”状态下的动画,您可以单击其中一个层上的 Sync 复选框,然后选择要同步的层。随后状态机的结构便会相同,但状态使用的实际动画剪辑不同。
这意味着同步的层根本没有自己的状态机定义,而是同步层状态机的一个实例。在同步层视图中对状态机的布局或结构所做的任何更改(例如,添加/删除状态或过渡)都是针对同步层的源进行的。同步层的唯一独特更改是每个状态内使用的选定动画。
通过 Timing 复选框,Animator 可调整同步层中每个动画所需的时间(由权重决定)。如果取消选中 Timing,则会调整同步层上的动画。该调整会将动画的长度拉伸到与原始层上的一致。如果选中该选项,则动画长度将在两个动画之间平衡(基于权重)。在两种情况下(选中和不选中),Animator 都将调整动画的长度。如果不选中,则原始层将是唯一母版。如果选中,则采用折中方案。
Layers 侧边栏中显示“S”符号,表示该层是同步层。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.