Up to date

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

AnimationNodeTransition

继承: AnimationNodeSync < AnimationNode < Resource < RefCounted < Object

AnimationTree 中连接两个 AnimationNode 的过渡。

描述

适用于不需要更高级 AnimationNodeStateMachine 的情况的简单状态机。可以将动画连接到输入,还可以指定过渡时间。

设置请求并更改动画播放后,过渡节点会在下一个处理帧中通过将其 transition_request 值设置为空,来自动清除请求。

注意:使用交叉淡入淡出时,current_statecurrent_index 在交叉淡入淡出开始后立即更改为下一个状态。

# 播放连接到 “state_2” 端口的子动画。
animation_tree.set("parameters/Transition/transition_request", "state_2")
# 替代语法(与上述结果相同)。
animation_tree["parameters/Transition/transition_request"] = "state_2"

# 获取当前状态名称(只读)。
animation_tree.get("parameters/Transition/current_state")
# 替代语法(与上述结果相同)。
animation_tree["parameters/Transition/current_state"]

# 获取当前状态索引(只读)。
animation_tree.get("parameters/Transition/current_index"))
# 替代语法(与上述结果相同)。
animation_tree["parameters/Transition/current_index"]

教程

属性

bool

allow_transition_to_self

false

int

input_count

0

Curve

xfade_curve

float

xfade_time

0.0

方法

bool

is_input_reset ( int input ) const

bool

is_input_set_as_auto_advance ( int input ) const

void

set_input_as_auto_advance ( int input, bool enable )

void

set_input_reset ( int input, bool enable )


属性说明

bool allow_transition_to_self = false

  • void set_allow_transition_to_self ( bool value )

  • bool is_allow_transition_to_self ( )

如果为 true,允许过渡到当前状态。当在输入中启用重置选项时,动画将重新启动。如果为 false,则在过渡到 当前状态时不会发生任何事情。


int input_count = 0

  • void set_input_count ( int value )

  • int get_input_count ( )

这个动画节点启用的输入端口的数量。


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 ( )

连接到输入的每个动画之间的交叉渐变时间(秒)。


方法说明

bool is_input_reset ( int input ) const

返回当动画从另一个动画过渡时,该动画是否重新开始。


bool is_input_set_as_auto_advance ( int input ) const

如果为给定的 input 索引启用了自动前进,则返回 true


void set_input_as_auto_advance ( int input, bool enable )

为给定的 input 索引启用或禁用自动前进。如果启用,状态会在播放一次动画后更改为下一个输入。如果为最后一个输入状态启用,它会循环到第一个。


void set_input_reset ( int input, bool enable )

如果为 true,则目标动画在动画过渡时重新启动。