Up to date
This page is up to date for Godot 4.2
.
If you still find outdated information, please open an issue.
AnimationNode¶
继承: Resource < RefCounted < Object
派生: AnimationNodeOutput, AnimationNodeSync, AnimationNodeTimeScale, AnimationNodeTimeSeek, AnimationRootNode
AnimationTree 节点的基类。与场景节点无关。
描述¶
AnimationTree 节点的基础资源。通常不会直接使用,但你可以使用自定义混合公式创建自定义节点。
创建动画节点时继承这个类主要是用在 AnimationNodeBlendTree 中,否则应改用 AnimationRootNode。
教程¶
属性¶
方法¶
_get_caption ( ) virtual const |
|
_get_child_by_name ( StringName name ) virtual const |
|
_get_child_nodes ( ) virtual const |
|
_get_parameter_default_value ( StringName parameter ) virtual const |
|
_get_parameter_list ( ) virtual const |
|
_has_filter ( ) virtual const |
|
_is_parameter_read_only ( StringName parameter ) virtual const |
|
_process ( float time, bool seek, bool is_external_seeking, bool test_only ) virtual const |
|
void |
blend_animation ( StringName animation, float time, float delta, bool seeked, bool is_external_seeking, float blend, LoopedFlag looped_flag=0 ) |
blend_input ( int input_index, float time, bool seek, bool is_external_seeking, float blend, FilterAction filter=0, bool sync=true, bool test_only=false ) |
|
blend_node ( StringName name, AnimationNode node, float time, bool seek, bool is_external_seeking, float blend, FilterAction filter=0, bool sync=true, bool test_only=false ) |
|
find_input ( String name ) const |
|
get_input_count ( ) const |
|
get_input_name ( int input ) const |
|
get_parameter ( StringName name ) const |
|
is_path_filtered ( NodePath path ) const |
|
void |
remove_input ( int index ) |
void |
set_filter_path ( NodePath path, bool enable ) |
set_input_name ( int input, String name ) |
|
void |
set_parameter ( StringName name, Variant value ) |
信号¶
animation_node_removed ( int object_id, String name )
由继承自该类的节点发出,并且当其中一个动画节点移除时具有内部树。发出此信号的动画节点可以是 AnimationNodeBlendSpace1D、AnimationNodeBlendSpace2D、AnimationNodeStateMachine 和 AnimationNodeBlendTree。
animation_node_renamed ( int object_id, String old_name, String new_name )
由继承自该类的节点发出,并且当其中一个动画节点名称更改时具有内部树。发出此信号的动画节点可以是 AnimationNodeBlendSpace1D、AnimationNodeBlendSpace2D、AnimationNodeStateMachine 和 AnimationNodeBlendTree。
tree_changed ( )
由继承自该类的节点发出,并且当其一个动画节点发生变化时具有内部树。发出此信号的动画节点可以是 AnimationNodeBlendSpace1D、AnimationNodeBlendSpace2D、AnimationNodeStateMachine、AnimationNodeBlendTree 和 AnimationNodeTransition。
枚举¶
enum FilterAction:
FilterAction FILTER_IGNORE = 0
不要使用筛选功能。
FilterAction FILTER_PASS = 1
与筛选器匹配的路径将被允许通过。
FilterAction FILTER_STOP = 2
与筛选器匹配的路径将被丢弃。
FilterAction FILTER_BLEND = 3
与筛选器匹配的路径将被混合(根据混合值)。
属性说明¶
bool filter_enabled
如果为 true
,则启用筛选功能。
方法说明¶
String _get_caption ( ) virtual const
继承 AnimationRootNode 时,实现这个虚方法可以覆盖这个动画节点的标题文本。
AnimationNode _get_child_by_name ( StringName name ) virtual const
继承 AnimationRootNode 时,实现这个虚方法可以根据名称 name
来返回对应的子动画节点。
Dictionary _get_child_nodes ( ) virtual const
继承 AnimationRootNode 时,实现这个虚方法可以用 名称:节点
字典的形式按顺序返回所有子动画节点。
Variant _get_parameter_default_value ( StringName parameter ) virtual const
继承 AnimationRootNode 时,实现这个虚方法可以返回参数“parameter
”的默认值。参数是动画节点的自定义本地存储,资源可以在多个树中重用。
Array _get_parameter_list ( ) virtual const
继承 AnimationRootNode 时,实现这个虚方法可以返回这个节点的属性列表。参数是动画节点的自定义本地存储,资源可以在多个树中重用。格式与 Object.get_property_list 类似。
bool _has_filter ( ) virtual const
继承 AnimationRootNode 时,实现这个虚方法可以返回混合树编辑器是否应该在这个动画节点上显示过滤器编辑。
bool _is_parameter_read_only ( StringName parameter ) virtual const
继承 AnimationRootNode 时,实现这个虚方法可以返回参数 parameter
是否只读。参数是动画节点的自定义本地存储,资源可以在多个树中重用。
float _process ( float time, bool seek, bool is_external_seeking, bool test_only ) virtual const
继承 AnimationRootNode 时,实现这个虚方法可以在这个动画节点进行处理时执行代码。参数 time
是相对增量,除非 seek
为 true
,此时为绝对增量。
请在此处调用 blend_input、blend_node 或 blend_animation 函数。你也可以使用 get_parameter 和 set_parameter 来修改本地存储。
这个函数应当返回当前动画还需多少时间完成(不确定的话,请传递调用主混合的值)。
bool add_input ( String name )
为节点添加一个输入。这只对创建用于 AnimationNodeBlendTree 的动画节点有用。如果添加失败,返回 false
。
void blend_animation ( StringName animation, float time, float delta, bool seeked, bool is_external_seeking, float blend, LoopedFlag looped_flag=0 )
按 blend
量混合一个动画(名称必须在链接的 AnimationPlayer 中有效)。可以传入时间 time
和增量 delta
,以及表示是否发生寻道的 seeked
。
looped_flag
在循环后立即由内部处理使用。另见 LoopedFlag。
float blend_input ( int input_index, float time, bool seek, bool is_external_seeking, float blend, FilterAction filter=0, bool sync=true, bool test_only=false )
混合一个输入。这只对为 AnimationNodeBlendTree 创建的动画节点有用。时间参数 time
是一个相对的增量,除非 seek
是 true
,此时它是绝对的。可以选择传入过滤模式(选项请参阅 FilterAction)。
float blend_node ( StringName name, AnimationNode node, float time, bool seek, bool is_external_seeking, float blend, FilterAction filter=0, bool sync=true, bool test_only=false )
混合另一个动画节点(在这个动画节点包含子动画节点的情况下)。这个函数只有在你继承 AnimationRootNode 时才有用,否则编辑器在添加节点时不会显示你的动画节点。
int find_input ( String name ) const
返回与名称 name
相关的输入索引,如果不存在则返回 -1
。
int get_input_count ( ) const
这个动画节点的输入数量,只对进入 AnimationNodeBlendTree 的动画节点有用。
String get_input_name ( int input ) const
通过索引获取输入的名称。
Variant get_parameter ( StringName name ) const
获取一个参数的值。参数是你的动画节点使用的自定义本地内存,给定的资源可以在多个树中重复使用。
bool is_path_filtered ( NodePath path ) const
返回给定路径是否被过滤。
void remove_input ( int index )
移除输入,仅在处于非活动状态时调用此输入。
void set_filter_path ( NodePath path, bool enable )
添加或移除筛选器的路径。
bool set_input_name ( int input, String name )
在给定的 input
索引处设置输入的名称。如果设置失败,返回 false
。
void set_parameter ( StringName name, Variant value )
设置一个自定义参数。这些参数被用作本地内存,因为资源可以在树或场景中重复使用。