Version: 2022.3
Animator 组件
创建AnimatorController

Animator Controller

Animator Controller 允许您为角色或对象安排和维护一组动画剪辑以及关联的动画过渡。在大多数情况下,拥有多个动画并在满足某些游戏条件时在这些动画之间切换是很常见的。例如,只要按下空格键,就可以从行走动画剪辑切换到跳跃动画剪辑。但是,即使您仅有一个动画剪辑,仍需要将其放入 Animator Controller 以便将其用于游戏对象。

The Animator Controller has references to the Animation clips used within it, and manages the various Animation Clips and the Transitions between them using a State Machine, which could be thought of as a flow-chart of Animation Clips and Transitions, or a simple program written in a visual programming language within Unity. More information about state machines can be found here.

简单的Animator Controller
简单的Animator Controller

开始使用 Animation 窗口对游戏对象进行动画化时,或者将动画剪辑附加到游戏对象时,Unity 会自动创建 Animator Controller。

To manually create an Animator Controller, right-click within either column of the Project window and select Create > Animator Controller.

导航

Use the scroll wheel to zoom in and zoom out of the Animator Controller window.

要聚焦 Animator Controller 窗口中的某一项,请选择一个或多个状态(单击要选择的状态或在其周围拖动选框),然后按 F 键来放大所选项。

聚焦所选状态
聚焦所选状态

按 A 键可将所有动画状态调整到 Animator Controller 视图中。

Unity 将保存您的选择。按 A 和 F 键可在所选动画状态与整个 Animator Controller 之间切换。

按 A 键时,Unity 将所有状态自动调整到 Animator Controller 视图中
按 A 键时,Unity 将所有状态自动调整到 Animator Controller 视图中

在播放模式期间,Animator 会平移视图,以便始终能看到正在播放的当前状态。Animator Controller 遵循基础层和子状态机的独立缩放因子,而窗口将自动平移以确保活动状态的可见性。

要在播放模式下修改缩放,请遵循以下步骤:

  • Enable Auto Live Link in the Animator Controller window.
  • Click the Play button to enter Play Mode.
  • Click Pause.
  • In the Animator Controller, select the state or states you want to zoom into.
  • Press the F key to zoom into the selection.
  • Click the Play button again to resume Play Mode.

请注意,Animator Controller 在激活时会平移到每个状态。

Animator 平移到活动状态
Animator 平移到活动状态

AnimatorController

Animator 组件
创建AnimatorController