状态机的基本思想是使角色在某一给定时刻进行一个特定的动作。动作类型可因游戏类型的不同而不同,常用的动作包括空闲、行走、跑步、跳跃等,其中每一个动作被称为__一种状态。在某种意义上,角色处于行走、空闲或者其它的“状态”中。一般来说,角色从一个状态立即切换到另一个状态是需要一定的限制条件的。比如角色只能从跑步状态切换到跑跳状态,而不能直接由静止状态切换到跑跳状态。角色从当前状态进入下一个状态的选项被称为状态过渡条件。状态集合、状态过渡条件以及记录当前状态的变量放在一起,形成了一个__状态机。
状态及其过渡条件可以通过图形来表达,其中的节点表示状态,而弧线(节点间的箭头)表示状态过渡。您可以将当前状态视为放置在节点之一上的标记或亮点,然后只能沿箭头之一跳转到另一个节点。
状态机对于动画的重要意义在于用户可以通过很少的代码对状态机进行设计和升级。每一个状态有一个与之关联的运动,只要状态机处于此状态,就会播放此运动。从而让动画师或设计师方便地定义动作顺序,而不必去关心底层代码的实现。
Unity的动画状态机提供了一种纵览角色所有动画剪辑的方法,并且允许通过游戏中的各种事件(如用户输入)来触发不同的动画效果。
动画状态机可以通过 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.