Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
AnimationNodeStateMachine¶
继承: AnimationRootNode < AnimationNode < Resource < RefCounted < Object
带有多个 AnimationRootNode 的状态机,用于 AnimationTree。
描述¶
包含表示动画状态的多个 AnimationRootNode,以图的形式连接。可以使用最短路径算法,将节点过渡配置为自动发生或通过代码发生。要以编程的方式控制过渡,请从 AnimationTree 节点获取 AnimationNodeStateMachinePlayback 对象。
示例:
var state_machine = $AnimationTree.get("parameters/playback")
state_machine.travel("some_state")
var stateMachine = GetNode<AnimationTree>("AnimationTree").Get("parameters/playback") as AnimationNodeStateMachinePlayback;
stateMachine.Travel("some_state");
教程¶
属性¶
|
||
|
||
|
方法¶
void |
add_node ( StringName name, AnimationNode node, Vector2 position=Vector2(0, 0) ) |
void |
add_transition ( StringName from, StringName to, AnimationNodeStateMachineTransition transition ) |
get_graph_offset ( ) const |
|
get_node ( StringName name ) const |
|
get_node_name ( AnimationNode node ) const |
|
get_node_position ( StringName name ) const |
|
get_transition ( int idx ) const |
|
get_transition_count ( ) const |
|
get_transition_from ( int idx ) const |
|
get_transition_to ( int idx ) const |
|
has_node ( StringName name ) const |
|
has_transition ( StringName from, StringName to ) const |
|
void |
remove_node ( StringName name ) |
void |
remove_transition ( StringName from, StringName to ) |
void |
remove_transition_by_index ( int idx ) |
void |
rename_node ( StringName name, StringName new_name ) |
void |
replace_node ( StringName name, AnimationNode node ) |
void |
set_graph_offset ( Vector2 offset ) |
void |
set_node_position ( StringName name, Vector2 position ) |
枚举¶
enum StateMachineType:
StateMachineType STATE_MACHINE_TYPE_ROOT = 0
寻道到开头被视为从开始状态开始播放。过渡到结束状态被视为退出状态机。
StateMachineType STATE_MACHINE_TYPE_NESTED = 1
寻道到开头被视为在当前状态下寻道到动画的开头。过渡到结束状态,或每个状态的过渡都缺失,被视为退出状态机。
StateMachineType STATE_MACHINE_TYPE_GROUPED = 2
这是一个可以从父状态机控制的编组的状态机。它不能独立运行。父级或祖先中必须有一个 state_machine_type 为 STATE_MACHINE_TYPE_ROOT 或 STATE_MACHINE_TYPE_NESTED 的状态机。
属性说明¶
bool allow_transition_to_self = false
如果为 true
,允许使用 AnimationNodeStateMachinePlayback.travel 传送到当前状态。当在 AnimationNodeStateMachinePlayback.travel 中启用重置选项时,动画将重新启动。如果为 false
,传送到当前状态时不会发生任何事情。
bool reset_ends = false
如果为 true
,则将与开始和结束节点的淡入淡出视为与 RESET 动画的混合。
大多数情况下,状态机的父级 AnimationNode 执行额外的淡入淡出时,将这个属性设置为 false
并将父 AnimationNode 和该状态机的开始和结束节点的淡入淡出时间设为相同的值能够得到不错的效果。
StateMachineType state_machine_type = 0
void set_state_machine_type ( StateMachineType value )
StateMachineType get_state_machine_type ( )
该属性可以为不同用例定义过渡过程。另见 StateMachineType。
方法说明¶
void add_node ( StringName name, AnimationNode node, Vector2 position=Vector2(0, 0) )
向图中添加一个新的动画节点。position
用于在编辑器中显示。
void add_transition ( StringName from, StringName to, AnimationNodeStateMachineTransition transition )
在给定动画节点之间添加一个过渡。
Vector2 get_graph_offset ( ) const
返回图的绘制偏移。用于在编辑器中显示。
AnimationNode get_node ( StringName name ) const
返回指定名称的动画节点。
StringName get_node_name ( AnimationNode node ) const
返回指定动画节点的名称。
Vector2 get_node_position ( StringName name ) const
返回给定动画节点的坐标。用于在编辑器中显示。
AnimationNodeStateMachineTransition get_transition ( int idx ) const
返回给定的过渡。
int get_transition_count ( ) const
返回图中的连接数。
StringName get_transition_from ( int idx ) const
返回给定过渡的开始节点。
StringName get_transition_to ( int idx ) const
返回给定过渡的末端节点。
bool has_node ( StringName name ) const
如果图中包含给定的动画节点,则返回 true
。
bool has_transition ( StringName from, StringName to ) const
如果在给定动画节点之间存在过渡,则返回 true
。
void remove_node ( StringName name )
从图中删除指定的动画节点。
void remove_transition ( StringName from, StringName to )
删除两个指定动画节点之间的过渡。
void remove_transition_by_index ( int idx )
按索引删除给定的过渡。
void rename_node ( StringName name, StringName new_name )
重命名给定的动画节点。
void replace_node ( StringName name, AnimationNode node )
目前没有这个方法的描述。请帮我们贡献一个!
void set_graph_offset ( Vector2 offset )
设置图形的绘制偏移。用于在编辑器中显示。
void set_node_position ( StringName name, Vector2 position )
设置动画节点的坐标。用于在编辑器中显示。