Index · Object → RefCounted → Resource → AnimationNode → AnimationRootNode → AnimationNodeBlendSpace2D

AnimationNodeBlendSpace2D

A set of AnimationRootNodes placed on 2D coordinates, crossfading between the three adjacent ones. Used by AnimationTree.

Class Description

A resource used by AnimationNodeBlendTree.

AnimationNodeBlendSpace2D represents a virtual 2D space on which AnimationRootNodes are placed. Outputs the linear blend of the three adjacent animations using a Vector2 weight. Adjacent in this context means the three AnimationRootNodes making up the triangle that contains the current value.

You can add vertices to the blend space with add_blend_point() and automatically triangulate it by setting auto_triangles to true. Otherwise, use add_triangle() and remove_triangle() to triangulate the blend space by hand.

Properties

var auto_triangles: bool = true

If true, the blend space is triangulated automatically. The mesh updates every time you add or remove points with add_blend_point() and remove_blend_point().

var blend_mode: AnimationNodeBlendSpace2D.BlendMode = 0

Controls the interpolation between animations.

var cyclic_length: float = 0.0

The cycle length in seconds used by SYNC_MODE_CYCLIC_CONSTANT. All animations are time-scaled so they complete one full cycle in this duration. Must be greater than 0 for cyclic sync to take effect.

var max_space: Vector2 = Vector2(1, 1)

The blend space's X and Y axes' upper limit for the points' position. See add_blend_point().

var min_space: Vector2 = Vector2(-1, -1)

The blend space's X and Y axes' lower limit for the points' position. See add_blend_point().

var snap: Vector2 = Vector2(0.1, 0.1)

Position increment to snap to when moving a point.

var sync: bool

If true, sync mode is enabled (equivalent to SYNC_MODE_INDEPENDENT). This property is kept for backward compatibility.

var sync_mode: AnimationNodeBlendSpace2D.SyncMode = 0

Controls how animations are synced when blended. See SyncMode for available options.

var x_label: String = "x"

Name of the blend space's X axis.

var y_label: String = "y"

Name of the blend space's Y axis.

Inherited from AnimationNode (1)
Inherited from Resource (4)

Methods

func add_blend_point(node: AnimationRootNode, pos: Vector2, at_index: int = -1, name: StringName = &"") -> void

Adds a new point with name that represents a node at the position set by pos. You can insert it at a specific index using the at_index argument. If you use the default value for at_index, the point is inserted at the end of the blend points array.

Note: If no name is provided, safe index is used as reference. In the future, empty names will be deprecated, so explicitly passing a name is recommended.

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

Creates a new triangle using three points x, y, and z. Triangles can overlap. You can insert the triangle at a specific index using the at_index argument. If you use the default value for at_index, the point is inserted at the end of the blend points array.

func find_blend_point_by_name(name: StringName) -> int

Returns the index of the blend point with the given name. Returns -1 if no blend point with that name is found.

func get_blend_point_count() -> int

Returns the number of points in the blend space.

func get_blend_point_name(point: int) -> StringName

Returns the name of the blend point at index point.

func get_blend_point_node(point: int) -> AnimationRootNode

Returns the AnimationRootNode referenced by the point at index point.

func get_blend_point_position(point: int) -> Vector2

Returns the position of the point at index point.

func get_triangle_count() -> int

Returns the number of triangles in the blend space.

func get_triangle_point(triangle: int, point: int) -> int

Returns the position of the point at index point in the triangle of index triangle.

func remove_blend_point(point: int) -> void

Removes the point at index point from the blend space.

func remove_triangle(triangle: int) -> void

Removes the triangle at index triangle from the blend space.

func reorder_blend_point(from_index: int, to_index: int) -> void

Swaps the blend points at indices from_index and to_index, exchanging their positions and properties.

func set_blend_point_name(point: int, name: StringName) -> void

Sets the name of the blend point at index point. If the name conflicts with an existing point, a unique name will be generated automatically.

func set_blend_point_node(point: int, node: AnimationRootNode) -> void

Changes the AnimationNode referenced by the point at index point.

func set_blend_point_position(point: int, pos: Vector2) -> void

Updates the position of the point at index point in the blend space.

Inherited from AnimationNode (23)
func _has_filter() -> bool
func _process(time: float, seek: bool, is_external_seeking: bool, test_only: bool) -> float
func add_input(name: String) -> bool
func blend_animation(animation: StringName, time: float, delta: float, seeked: bool, is_external_seeking: bool, blend: float, looped_flag: Animation.LoopedFlag = 0) -> void
func blend_input(input_index: int, time: float, seek: bool, is_external_seeking: bool, blend: float, filter: AnimationNode.FilterAction = 0, sync: bool = true, test_only: bool = false) -> float
func blend_node(name: StringName, node: AnimationNode, time: float, seek: bool, is_external_seeking: bool, blend: float, filter: AnimationNode.FilterAction = 0, sync: bool = true, test_only: bool = false) -> float
func find_input(name: String) -> int
func get_input_name(input: int) -> String
func remove_input(index: int) -> void
func set_filter_path(path: NodePath, enable: bool) -> void
func set_input_name(input: int, name: String) -> bool
func set_parameter(name: StringName, value: Variant) -> void
Inherited from Resource (18)
func _get_rid() -> RID
func _reset_state() -> void
func _set_path_cache(path: String) -> void
func _setup_local_to_scene() -> void
func copy_from_resource(resource: Resource) -> Error
func duplicate(deep: bool = false) -> Resource
func duplicate_deep(deep_subresources_mode: Resource.DeepDuplicateMode = 1) -> Resource
func emit_changed() -> void
func get_rid() -> RID
func is_built_in() -> bool
func reset_state() -> void
func set_id_for_path(path: String, id: String) -> void
func set_path_cache(path: String) -> void
func setup_local_to_scene() -> void
func take_over_path(path: String) -> void
Inherited from RefCounted (4)
func init_ref() -> bool
func reference() -> bool
func unreference() -> bool
Inherited from Object (62)
func _get(property: StringName) -> Variant
func _get_property_list() -> Dictionary[]
func _init() -> void
func _iter_get(iter: Variant) -> Variant
func _iter_init(iter: Array) -> bool
func _iter_next(iter: Array) -> bool
func _notification(what: int) -> void
func _set(property: StringName, value: Variant) -> bool
func _to_string() -> String
func _validate_property(property: Dictionary) -> void
func add_user_signal(signal: String, arguments: Array = []) -> void
func call(method: StringName) -> Variant
func callv(method: StringName, arg_array: Array) -> Variant
func cancel_free() -> void
func connect(signal: StringName, callable: Callable, flags: int = 0) -> Error
func disconnect(signal: StringName, callable: Callable) -> void
func emit_signal(signal: StringName) -> Error
func free() -> void
func get(property: StringName) -> Variant
func get_class() -> String
func get_incoming_connections() -> Dictionary[]
func get_indexed(property_path: NodePath) -> Variant
func get_meta(name: StringName, default: Variant = null) -> Variant
func get_meta_list() -> StringName[]
func get_method_list() -> Dictionary[]
func get_property_list() -> Dictionary[]
func get_signal_connection_list(signal: StringName) -> Dictionary[]
func get_signal_list() -> Dictionary[]
func has_meta(name: StringName) -> bool
func has_method(method: StringName) -> bool
func has_signal(signal: StringName) -> bool
func is_class(class: StringName) -> bool
func is_connected(signal: StringName, callable: Callable) -> bool
func notification(what: int, reversed: bool = false) -> void
func remove_meta(name: StringName) -> void
func remove_user_signal(signal: StringName) -> void
func set(property: StringName, value: Variant) -> void
func set_block_signals(enable: bool) -> void
func set_deferred(property: StringName, value: Variant) -> void
func set_indexed(property_path: NodePath, value: Variant) -> void
func set_message_translation(enable: bool) -> void
func set_meta(name: StringName, value: Variant) -> void
func set_script(script: Variant) -> void
func set_translation_domain(domain: StringName) -> void
func to_string() -> String
func tr(message: StringName, context: StringName = &"") -> String
func tr_n(message: StringName, plural_message: StringName, n: int, context: StringName = &"") -> String

Signals

signal triangles_updated()

Emitted every time the blend space's triangles are created, removed, or when one of their vertices changes position.

Inherited from AnimationNode (4)
signal animation_node_removed(object_id: int, node_name: String)
signal animation_node_renamed(object_id: int, old_name: String, new_name: String)
signal node_updated(object_id: int)
signal tree_changed()
Inherited from Resource (2)
signal changed()
Inherited from Object (2)

Enums & Constants

enum BlendMode
BLEND_MODE_INTERPOLATED = 0

The interpolation between animations is linear.

BLEND_MODE_DISCRETE = 1

The blend space plays the animation of the animation node which blending position is closest to. Useful for frame-by-frame 2D animations.

BLEND_MODE_DISCRETE_CARRY = 2

Similar to BLEND_MODE_DISCRETE, but starts the new animation at the last animation's playback position.

enum SyncMode
SYNC_MODE_NONE = 0

Inactive animations are frozen and do not advance.

SYNC_MODE_INDEPENDENT = 1

Inactive animations advance with a weight of 0. This is equivalent to the previous sync = true behavior.

SYNC_MODE_CYCLIC_MUTABLE = 2

All animations are time-scaled so they stay in sync, with the cycle length dynamically computed from active blend weights. This is self-normalizing: a solo animation plays at normal speed.

Note: If you apply AnimationNodeTimeSeek to the result when handling animations of different lengths, synchronization will be broken. In such cases, it is recommended to use AnimationNodeAnimation.use_custom_timeline to align the animation lengths.

SYNC_MODE_CYCLIC_CONSTANT = 3

All animations are time-scaled so they complete one cycle in cyclic_length seconds, keeping them in sync regardless of their individual lengths.

Note: If you apply AnimationNodeTimeSeek to the result when handling animations of different lengths, synchronization will be broken. In such cases, it is recommended to use AnimationNodeAnimation.use_custom_timeline to align the animation lengths.