AnimationNode¶
继承: Resource < RefCounted < Object
派生: AnimationNodeExtension, AnimationNodeOutput, AnimationNodeSync, AnimationNodeTimeScale, AnimationNodeTimeSeek, AnimationRootNode
AnimationTree节点的基类。与场景节点无关。
描述¶
AnimationTree节点的基本资源。一般情况下,它不直接使用,但您可以使用自定义混合公式创建自定义。
在创建主要用于AnimationNodeBlendTree的动画节点时继承这一点,否则应该使用AnimationRootNode。
您可以将时间信息作为只读参数访问,该参数被处理并存储在除AnimationNodeOutput之外的所有节点的前一帧中。
注意:如果AnimationNode中存在多个输入,则哪个时间信息优先取决于AnimationNode的类型。
var current_length = $AnimationTree[parameters/AnimationNodeName/current_length]
var current_position = $AnimationTree[parameters/AnimationNodeName/current_position]
var current_delta = $AnimationTree[parameters/AnimationNodeName/current_delta]
属性¶
方法¶
_get_caption() virtual const |
|
_get_child_by_name(name: StringName) virtual const |
|
_get_child_nodes() virtual const |
|
_get_parameter_default_value(parameter: StringName) virtual const |
|
_get_parameter_list() virtual const |
|
_has_filter() virtual const |
|
_is_parameter_read_only(parameter: StringName) virtual const |
|
_process(time: float, seek: bool, is_external_seeking: bool, test_only: bool) virtual |
|
void |
blend_animation(animation: StringName, time: float, delta: float, seeked: bool, is_external_seeking: bool, blend: float, looped_flag: LoopedFlag = 0) |
blend_input(input_index: int, time: float, seek: bool, is_external_seeking: bool, blend: float, filter: FilterAction = 0, sync: bool = true, test_only: bool = false) |
|
blend_node(name: StringName, node: AnimationNode, time: float, seek: bool, is_external_seeking: bool, blend: float, filter: FilterAction = 0, sync: bool = true, test_only: bool = false) |
|
find_input(name: String) const |
|
get_input_count() const |
|
get_input_name(input: int) const |
|
get_parameter(name: StringName) const |
|
is_path_filtered(path: ItemPath) const |
|
is_process_testing() const |
|
void |
remove_input(index: int) |
void |
set_filter_path(path: ItemPath, enable: bool) |
set_input_name(input: int, name: String) |
|
void |
set_parameter(name: StringName, value: Variant) |
信号¶
animation_node_removed(object_id: int, name: String) 🔗
当其中一个动画节点删除时,由继承自此类且具有内部树的节点发出。发出此信号的动画节点是AnimationNodeBlendSpace1D、AnimationNodeBlendSpace2D、AnimationNodeStateMachine和AnimationNodeBlendTree。
animation_node_renamed(object_id: int, old_name: String, new_name: String) 🔗
由继承自此类且具有内部树的节点在其动画节点名称之一更改时发出。发出此信号的动画节点是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
匹配过滤器的路径将被混合(通过混合值)。
属性说明¶
如果true,则启用过滤。
方法说明¶
String _get_caption() virtual const 🔗
从AnimationRootNode继承时,实现此虚拟方法以覆盖此动画节点的文本标题。
AnimationNode _get_child_by_name(name: StringName) virtual const 🔗
从AnimationRootNode继承时,实现此虚拟方法以通过其name返回子动画节点。
Dictionary _get_child_nodes() virtual const 🔗
从AnimationRootNode继承时,实现此虚拟方法以按name: node字典的顺序返回所有子动画节点。
Variant _get_parameter_default_value(parameter: StringName) 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(parameter: StringName) virtual const 🔗
从AnimationRootNode继承时,实现此虚拟方法以返回parameter是否为只读。参数是用于动画节点的自定义本地内存,给定资源可以在多棵树中重用。
float _process(time: float, seek: bool, is_external_seeking: bool, test_only: bool) virtual 🔗
已弃用: 目前,这基本上是无用的,因为缺乏许多API来通过S3Script扩展AnimationNode。计划在未来提供更灵活的API使用结构。
从AnimationRootNode继承时,实现此虚方法以在处理此动画节点时运行一些代码,time参数是相对增量,除非seek是true,在这种情况下是绝对的。
这里调用blend_input()、blend_node()或blend_animation()函数,也可以使用get_parameter()和set_parameter()修改本地内存。
此函数应返回增量。
bool add_input(name: String) 🔗
向动画节点添加输入。这仅对为在AnimationNodeBlendTree中使用而创建的动画节点有用。如果添加失败,则返回false。
void blend_animation(animation: StringName, time: float, delta: float, seeked: bool, is_external_seeking: bool, blend: float, looped_flag: LoopedFlag = 0) 🔗
按blend量混合动画(名称必须在链接的AnimationPlayer中有效)。可以传递time和delta,以及是否发生了seeked。
looped_flag在循环后立即由内部处理使用。另请参见LoopedFlag。
float blend_input(input_index: int, time: float, seek: bool, is_external_seeking: bool, blend: float, filter: FilterAction = 0, sync: bool = true, test_only: bool = false) 🔗
混合输入。这仅对为AnimationNodeBlendTree创建的动画节点有用。time参数是相对增量,除非seek是true,在这种情况下它是绝对的。可以选择传递过滤模式(有关选项,请参阅FilterAction)。
float blend_node(name: StringName, node: AnimationNode, time: float, seek: bool, is_external_seeking: bool, blend: float, filter: FilterAction = 0, sync: bool = true, test_only: bool = false) 🔗
混合另一个动画节点(以防此动画节点包含子动画节点)。此功能仅在您从AnimationRootNode继承时有用,否则编辑器将不会显示您的动画节点以进行添加。
int find_input(name: String) const 🔗
返回name对应的输入索引。如果未找到,则返回-1。
此动画节点中的输入量,仅对进入AnimationNodeBlendTree的动画节点有用。
String get_input_name(input: int) const 🔗
按索引获取输入的名称。
Variant get_parameter(name: StringName) const 🔗
获取参数的值。参数是用于动画节点的自定义本地内存,给定资源可以在多个树中重用。
int get_processing_animation_tree_instance_id() const 🔗
返回拥有此节点的AnimationTree的对象ID。
注意:此方法只能从AnimationNodeExtension._process_animation_node()方法中调用,否则将返回无效的id。
bool is_path_filtered(path: ItemPath) const 🔗
如果过滤了给定路径,则返回true。
bool is_process_testing() const 🔗
如果此动画节点正在以仅测试模式处理,则返回true。
void remove_input(index: int) 🔗
删除输入,仅在非活动时调用this。
void set_filter_path(path: ItemPath, enable: bool) 🔗
添加或删除过滤器的路径。
bool set_input_name(input: int, name: String) 🔗
设置给定input索引处的输入名称。如果设置失败,则返回false。
void set_parameter(name: StringName, value: Variant) 🔗
设置自定义参数。这些用作本地内存,因为资源可以跨树或场景重用。