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...
AnimationNodeBlendSpace2D
继承: AnimationRootNode < AnimationNode < Resource < RefCounted < Object
一组放置在 2D 坐标上的 AnimationRootNode,在三个相邻节点之间交叉淡化。被 AnimationTree 使用。
描述
AnimationNodeBlendTree 使用的资源。
AnimationNodeBlendSpace2D 代表放置 AnimationRootNode 的虚拟 2D 空间。输出的是使用 Vector2 权重对相邻的三个动画进行线性混合的结果。此处的“相邻”指的是构成包含当前值的三角形的三个 AnimationRootNode。
你可以使用 add_blend_point() 向混合空间中添加顶点,将 auto_triangles 设为 true
可以将其自动三角形化。否则,请使用 add_triangle() 和 remove_triangle() 手动对混合空间进行三角形化。
教程
属性
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
方法
void |
add_blend_point(node: AnimationRootNode, pos: Vector2, at_index: int = -1) |
void |
add_triangle(x: int, y: int, z: int, at_index: int = -1) |
get_blend_point_count() const |
|
get_blend_point_node(point: int) const |
|
get_blend_point_position(point: int) const |
|
get_triangle_count() const |
|
get_triangle_point(triangle: int, point: int) |
|
void |
remove_blend_point(point: int) |
void |
remove_triangle(triangle: int) |
void |
set_blend_point_node(point: int, node: AnimationRootNode) |
void |
set_blend_point_position(point: int, pos: Vector2) |
信号
triangles_updated() 🔗
每当创建、移除混合空间的三角形,或当其中一个顶点改变位置时发出。
枚举
enum BlendMode: 🔗
BlendMode BLEND_MODE_INTERPOLATED = 0
动画之间的插值是线性的。
BlendMode BLEND_MODE_DISCRETE = 1
混合空间播放混合位置最接近的动画节点的动画。可用于逐帧的 2D 动画。
BlendMode BLEND_MODE_DISCRETE_CARRY = 2
类似于 BLEND_MODE_DISCRETE,但在最后一个动画的播放位置开始新的动画。
属性说明
如果为 true
,混合空间会自动进行三角测量。每次使用 add_blend_point() 和 remove_blend_point() 添加或移除点时,网格都会更新。
控制动画之间的插值。见 BlendMode 常量。
Vector2 max_space = Vector2(1, 1)
🔗
用于点的位置的混合空间的 X 轴和 Y 轴的上限。请参阅 add_blend_point()。
Vector2 min_space = Vector2(-1, -1)
🔗
用于点的位置的混合空间的 X 轴和 Y 轴的下限。请参阅 add_blend_point()。
Vector2 snap = Vector2(0.1, 0.1)
🔗
移动点时要吸附到的位置增量。
如果为 false
,则当混合值为 0
时,停止混合动画的帧。
如果为 true
,则强制混合动画以前进帧。
混合空间 X 轴的名称。
混合空间 Y 轴的名称。
方法说明
void add_blend_point(node: AnimationRootNode, pos: Vector2, at_index: int = -1) 🔗
在 pos
设定的位置添加一个代表 node
的新点。你可以使用 at_index
参数将其插入到特定的索引中。如果使用 at_index
的默认值,这个点会被插入到混合点数组的末尾。
void add_triangle(x: int, y: int, z: int, at_index: int = -1) 🔗
使用三个点 x
、y
和 z
创建一个新三角形。三角形可以重叠。可以使用 at_index
参数在特定索引处插入三角形。如果使用 at_index
的默认值,该点将插入到混合点数组的末尾。
int get_blend_point_count() const 🔗
返回混合空间中的点的数量。
AnimationRootNode get_blend_point_node(point: int) const 🔗
返回索引 point
处的点所引用的 AnimationRootNode。
Vector2 get_blend_point_position(point: int) const 🔗
返回索引 point
处的点的位置。
int get_triangle_count() const 🔗
返回混合空间中三角形的数量。
int get_triangle_point(triangle: int, point: int) 🔗
返回索引 point
处的点在索引 triangle
的三角形中的位置。
void remove_blend_point(point: int) 🔗
从混合空间中移除索引 point
处的点。
void remove_triangle(triangle: int) 🔗
从混合空间中移除索引 triangle
处的三角形。
void set_blend_point_node(point: int, node: AnimationRootNode) 🔗
更改索引 point
处的点所引用的 AnimationNode。
void set_blend_point_position(point: int, pos: Vector2) 🔗
更新混合空间中索引 point
处的点的位置。