Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

AnimationNodeBlendSpace2D

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

一组放置在 2D 坐标上的 AnimationRootNode,在三个相邻节点之间交叉淡化。被 AnimationTree 使用。

描述

AnimationNodeBlendTree 使用的资源。

AnimationNodeBlendSpace1D 代表放置 AnimationRootNode 的虚拟 2D 空间。输出的是使用 Vector2 权重对相邻的三个动画进行线性混合的结果。此处的“相邻”指的是构成包含当前值的三角形的三个 AnimationRootNode

你可以使用 add_blend_point 向混合空间中添加顶点,将 auto_triangles 设为 true 可以将其自动三角形化。否则,请使用 add_triangleremove_triangle 手动对混合空间进行三角形化。

教程

属性

bool

auto_triangles

true

BlendMode

blend_mode

0

Vector2

max_space

Vector2(1, 1)

Vector2

min_space

Vector2(-1, -1)

Vector2

snap

Vector2(0.1, 0.1)

bool

sync

false

String

x_label

"x"

String

y_label

"y"

方法

void

add_blend_point ( AnimationRootNode node, Vector2 pos, int at_index=-1 )

void

add_triangle ( int x, int y, int z, int at_index=-1 )

int

get_blend_point_count ( ) const

AnimationRootNode

get_blend_point_node ( int point ) const

Vector2

get_blend_point_position ( int point ) const

int

get_triangle_count ( ) const

int

get_triangle_point ( int triangle, int point )

void

remove_blend_point ( int point )

void

remove_triangle ( int triangle )

void

set_blend_point_node ( int point, AnimationRootNode node )

void

set_blend_point_position ( int point, Vector2 pos )


信号

triangles_updated ( )

每当创建、移除混合空间的三角形,或当其中一个顶点改变位置时发出。


枚举

enum BlendMode:

BlendMode BLEND_MODE_INTERPOLATED = 0

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

BlendMode BLEND_MODE_DISCRETE = 1

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

BlendMode BLEND_MODE_DISCRETE_CARRY = 2

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


属性说明

bool auto_triangles = true

  • void set_auto_triangles ( bool value )

  • bool get_auto_triangles ( )

如果为 true,混合空间会自动进行三角测量。每次使用 add_blend_pointremove_blend_point 添加或移除点时,网格都会更新。


BlendMode blend_mode = 0

控制动画之间的插值。见 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)

移动点时要吸附到的位置增量。


bool sync = false

  • void set_use_sync ( bool value )

  • bool is_using_sync ( )

如果为 false,则当混合值为 0 时,停止混合动画的帧。

如果为 true,则强制混合动画以前进帧。


String x_label = "x"

混合空间 X 轴的名称。


String y_label = "y"

混合空间 Y 轴的名称。


方法说明

void add_blend_point ( AnimationRootNode node, Vector2 pos, int at_index=-1 )

pos 设定的位置添加一个代表 node 的新点。你可以使用 at_index 参数将其插入到特定的索引中。如果使用 at_index 的默认值,这个点会被插入到混合点数组的末尾。


void add_triangle ( int x, int y, int z, int at_index=-1 )

使用三个点 xyz 创建一个新三角形。三角形可以重叠。可以使用 at_index 参数在特定索引处插入三角形。如果使用 at_index 的默认值,该点将插入到混合点数组的末尾。


int get_blend_point_count ( ) const

返回混合空间中的点的数量。


AnimationRootNode get_blend_point_node ( int point ) const

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


Vector2 get_blend_point_position ( int point ) const

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


int get_triangle_count ( ) const

返回混合空间中三角形的数量。


int get_triangle_point ( int triangle, int point )

返回索引 point 处的点在索引 triangle 的三角形中的位置。


void remove_blend_point ( int point )

从混合空间中移除索引 point 处的点。


void remove_triangle ( int triangle )

从混合空间中移除索引 triangle 处的三角形。


void set_blend_point_node ( int point, AnimationRootNode node )

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


void set_blend_point_position ( int point, Vector2 pos )

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