Animator Override Controller 是一种资源,它可让您扩展现有 Animator Controller,从而替换使用的特定动画但保留其原始结构、参数和逻辑。
因此,您可以创建同一个基本状态机的多个变体,但是每个变体使用不同的动画集。例如,您的游戏可能有各种各样的 NPC 类角色生活在世界上,但每种类型(小妖精、恶魔、小精灵等)都有自己独特的行走、空闲、坐定等动画。
通过创建一个包含所有 NPC 类型角色逻辑的“基础”Animator Controller,即可为每种角色类型创建一个重写,并放入各自的动画文件。
以下是一个用于演示的典型Animator Controller资源:
这代表一个Animator Controller,其中包含一个简单状态机,由混合树控制四个方向的动画,还有一个空闲动画,如下所示:
To extend this general NPC state machine to use unique animations which just apply to - say - an ogre-type character, you can create an Animator Override Controller and drop in the Ogre’s animation clips as replacements to the original animation clips. The Ogre may have a different way of idling and moving around, perhaps with slower, heavier and more muscular motion. However, using an Animator Override Controller, the basic logic for how to transition and blend between movement states can be shared between different characters with different sets of animation, reducing the work required building and modifying state machines themselves.
要创建新的Animator Override Controller,请使用 Assets > Create 菜单,或 Project 视图中的 Create 按钮,然后选择 Animator Override Controller。
Animator Override Controller具有与Animator Controller非常相似的图标,不同之处在于它在图标角上带有“加号”而不是“播放”符号:
在检视面板中选择新的 Animator Override Controller 时,最初会处于未分配状态,如下所示:
要开始使用Override Controller,必须将原始控制器资源分配给检视面板中的新Override Controller。完成此操作后,原始控制器中使用的所有动画将在 Override Controller 的检视面板中显示为列表:
然后,您可以分配新动画剪辑以重写原始剪辑。在此示例中,已使用动画的“恶魔”(Ogre) 版本重写所有剪辑。
现在,此 Override Controller 可在Ogre角色的游戏对象的 Animator 组件中使用,就像它是 Animator Controller 一样。它将使用与原始 Animator Controller 相同的逻辑,但播放的是分配的新动画而不是原始动画。
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.