Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

AnimationNodeStateMachineTransition

继承: Resource < RefCounted < Object

AnimationNodeStateMachine 中连接两个 AnimationRootNode 的过渡。

描述

使用 AnimationNodeStateMachinePlayback.travel 时生成的路径,仅限于通过 AnimationNodeStateMachineTransition 连接的节点。

可以详细设置过渡的时机和条件。

教程

属性

StringName

advance_condition

&""

String

advance_expression

""

AdvanceMode

advance_mode

1

int

priority

1

bool

reset

true

SwitchMode

switch_mode

0

Curve

xfade_curve

float

xfade_time

0.0


信号

advance_condition_changed ( )

变更 advance_condition 时发出。


枚举

enum SwitchMode:

SwitchMode SWITCH_MODE_IMMEDIATE = 0

立即切换到下一个状态。当前状态将结束,并混合到新状态的开始。

SwitchMode SWITCH_MODE_SYNC = 1

立即切换到下一个状态,但会将新的状态定位到旧状态的播放位置。

SwitchMode SWITCH_MODE_AT_END = 2

等待当前状态播放结束,然后切换到下一个状态动画的开头。


enum AdvanceMode:

AdvanceMode ADVANCE_MODE_DISABLED = 0

不要使用该过渡。

AdvanceMode ADVANCE_MODE_ENABLED = 1

仅在 AnimationNodeStateMachinePlayback.travel 时使用该过渡。

AdvanceMode ADVANCE_MODE_AUTO = 2

如果 advance_conditionadvance_expression 检查为真,则自动使用该过渡(如果已分配)。


属性说明

StringName advance_condition = &""

该条件被设置时打开自动前进。提供的名称将成为 AnimationTree 上的布尔参数,可以通过代码进行控制(请参阅 使用 AnimationTree)。例如,如果 AnimationTree.tree_root 是一个 AnimationNodeStateMachine 并且 advance_condition 被设置为 "idle"

$animation_tree.set("parameters/conditions/idle", is_on_floor and (linear_velocity.x == 0))

String advance_expression = ""

  • void set_advance_expression ( String value )

  • String get_advance_expression ( )

将表达式用作状态机过渡的条件。可以为状态之间的切换创建复杂的动画推进条件,并通过直接与脚本代码交互为创建复杂的状态机提供更大的灵活性。


AdvanceMode advance_mode = 1

决定在使用 AnimationNodeStateMachinePlayback.travel 时该过渡是否应该被禁用/启用,或者如果 advance_conditionadvance_expression 检查为真则自动行进(如果已分配)。


int priority = 1

  • void set_priority ( int value )

  • int get_priority ( )

当在树中通过 AnimationNodeStateMachinePlayback.travel 或将 advance_mode 设置为 ADVANCE_MODE_AUTO 行进时,倾向于优先级较低的过渡。


bool reset = true

  • void set_reset ( bool value )

  • bool is_reset ( )

如果为 true,切换时目标动画从头开始播放。


SwitchMode switch_mode = 0

过渡类型。


Curve xfade_curve

  • void set_xfade_curve ( Curve value )

  • Curve get_xfade_curve ( )

缓动曲线可以更好地控制此状态和下一个状态之间的交叉淡入淡出。


float xfade_time = 0.0

  • void set_xfade_time ( float value )

  • float get_xfade_time ( )

这个状态和下一个状态之间的交叉渐变时间。