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...
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: NodePath) const |
|
is_process_testing() const |
|
void |
remove_input(index: int) |
void |
set_filter_path(path: NodePath, 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 时,实现这个虚方法可以用 名称:节点
字典的形式按顺序返回所有子动画节点。
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 🔗
已弃用: Currently this is mostly useless as there is a lack of many APIs to extend AnimationNode by GDScript. It is planned that a more flexible API using structures will be provided in the future.
继承 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: NodePath) const 🔗
如果给定的路径被过滤,则返回 true
。
bool is_process_testing() const 🔗
如果该动画节点正在仅测试模式下处理,则返回 true
。
void remove_input(index: int) 🔗
移除输入,仅在处于非活动状态时调用此输入。
void set_filter_path(path: NodePath, enable: bool) 🔗
添加或移除筛选器的路径。
bool set_input_name(input: int, name: String) 🔗
在给定的 input
索引处设置输入的名称。如果设置失败,返回 false
。
void set_parameter(name: StringName, value: Variant) 🔗
设置一个自定义参数。这些参数被用作本地内存,因为资源可以在树或场景中重复使用。