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.

AnimationNodeBlendSpace1D

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

一组放置在一个虚拟轴上的 AnimationRootNode,在两个相邻节点之间交叉淡化。被 AnimationTree 使用。

描述

可添加到 AnimationNodeBlendTree 的资源。

AnimationNodeBlendSpace1D 代表一个虚拟轴,可以使用 add_blend_point() 在上面添加任何类型的 AnimationRootNode。输出的是最接近当前值的两个 AnimationRootNode 之间的线性混合。

可以使用 min_spacemax_space 来扩展轴的范围。

教程

属性

BlendMode

blend_mode

0

float

cyclic_length

0.0

float

max_space

1.0

float

min_space

-1.0

float

snap

0.1

bool

sync

SyncMode

sync_mode

0

String

value_label

"value"

方法

void

add_blend_point(node: AnimationRootNode, pos: float, at_index: int = -1, name: StringName = &"")

int

find_blend_point_by_name(name: StringName) const

int

get_blend_point_count() const

StringName

get_blend_point_name(point: int) const

AnimationRootNode

get_blend_point_node(point: int) const

float

get_blend_point_position(point: int) const

void

remove_blend_point(point: int)

void

reorder_blend_point(from_index: int, to_index: int)

void

set_blend_point_name(point: int, name: StringName)

void

set_blend_point_node(point: int, node: AnimationRootNode)

void

set_blend_point_position(point: int, pos: float)


枚举

enum BlendMode: 🔗

BlendMode BLEND_MODE_INTERPOLATED = 0

动画之间的插值是线性的。

BlendMode BLEND_MODE_DISCRETE = 1

混合空间播放混合位置最接近的动画节点的动画。可用于逐帧的 2D 动画。

BlendMode BLEND_MODE_DISCRETE_CARRY = 2

类似于 BLEND_MODE_DISCRETE,但在最后一个动画的播放位置开始新的动画。


enum SyncMode: 🔗

SyncMode SYNC_MODE_NONE = 0

处于非活动状态的动画会被冻结,且不会继续播放(不会推进进度)。

SyncMode SYNC_MODE_INDEPENDENT = 1

非活动状态的动画会以 0 的权重继续播放(推进进度)。这等同于以前 sync = true 时的行为。

SyncMode SYNC_MODE_CYCLIC_MUTABLE = 2

所有动画都会进行时间缩放以保持同步,其周期长度会根据活动的混合权重动态计算。这是一种自我归一化(self-normalizing)的机制:当只有一个动画单独播放时,它会以正常速度播放。

注意: 如果你在混合不同长度的动画时,对结果应用了 AnimationNodeTimeSeek(时间查找)节点,同步将会被破坏。在这种情况下,建议使用 AnimationNodeAnimation.use_custom_timeline(使用自定义时间轴)来对齐动画的长度。

SyncMode SYNC_MODE_CYCLIC_CONSTANT = 3

所有动画都会进行时间缩放,以确保它们都在 cyclic_length 秒内刚好完成一个循环,从而让它们保持同步,完全不受各自原始长度的影响。

注意: 如果你在混合不同长度的动画时,对结果应用了 AnimationNodeTimeSeek(时间查找)节点,同步将会被破坏。在这种情况下,建议使用 AnimationNodeAnimation.use_custom_timeline(使用自定义时间轴)来对齐动画的长度。


属性说明

BlendMode blend_mode = 0 🔗

控制动画之间的插值。


float cyclic_length = 0.0 🔗

  • void set_cyclic_length(value: float)

  • float get_cyclic_length()

SYNC_MODE_CYCLIC_CONSTANT 模式所使用的周期长度(以秒为单位)。所有的动画都会进行时间缩放,以确保在这个时长内刚好完整地循环一次。该数值必须大于 0,循环同步(cyclic sync)才会生效。


float max_space = 1.0 🔗

  • void set_max_space(value: float)

  • float get_max_space()

用于点位置的混合空间轴的上限。见 add_blend_point()


float min_space = -1.0 🔗

  • void set_min_space(value: float)

  • float get_min_space()

用于点位置的混合空间轴的下限。见 add_blend_point()


float snap = 0.1 🔗

当在轴上移动一个点时,要捕捉到的位置增量。


bool sync 🔗

  • void set_use_sync(value: bool)

  • bool is_using_sync()

已弃用: Use sync_mode instead.

如果设为 true(真),则启用同步模式(等同于 SYNC_MODE_INDEPENDENT)。保留该属性是为了向后兼容。


SyncMode sync_mode = 0 🔗

控制动画在混合时的同步方式。可用的选项见 SyncMode


String value_label = "value" 🔗

  • void set_value_label(value: String)

  • String get_value_label()

混合空间虚拟轴的标签。


方法说明

void add_blend_point(node: AnimationRootNode, pos: float, at_index: int = -1, name: StringName = &"") 🔗

在虚拟轴上指定的 pos(位置)处,添加一个带有 name(名称)且代表 node(节点)的新点。你可以使用 at_index 参数将其插入到指定的索引位置。如果你使用 at_index 的默认值,该点会被插入到混合点数组的末尾。

注意: 如果没有提供名称,系统会使用安全的索引作为参考。未来空名称将会被弃用,因此强烈建议显式地传入一个名称。


int find_blend_point_by_name(name: StringName) const 🔗

返回具有给定 name 的混合点的索引。如果未找到具有该名称的混合点,则返回 -1


int get_blend_point_count() const 🔗

返回混合轴上的点的数量。


StringName get_blend_point_name(point: int) const 🔗

返回索引 point 处的混合点的名称。


AnimationRootNode get_blend_point_node(point: int) const 🔗

返回索引 point 处的点所引用的 AnimationNode


float get_blend_point_position(point: int) const 🔗

返回索引 point 处的点的位置。


void remove_blend_point(point: int) 🔗

从混合轴移除索引 point 处的点。


void reorder_blend_point(from_index: int, to_index: int) 🔗

交换位于 from_indexto_index 索引处的混合点(blend points),互换它们的位置和属性。


void set_blend_point_name(point: int, name: StringName) 🔗

设置索引为 point 的混合点的名称。如果该名称与现有的点发生冲突(即重名),系统会自动生成一个唯一的名称。


void set_blend_point_node(point: int, node: AnimationRootNode) 🔗

更改索引 point 处的点所引用的 AnimationNode


void set_blend_point_position(point: int, pos: float) 🔗

更新混合轴上索引 point 处的点的位置。