Files
godot-docs/classes/class_animationnodeblendspace2d.rst
2025-06-07 03:33:02 +00:00

440 lines
23 KiB
ReStructuredText

:github_url: hide
.. DO NOT EDIT THIS FILE!!!
.. Generated automatically from Godot engine sources.
.. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
.. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/AnimationNodeBlendSpace2D.xml.
.. _class_AnimationNodeBlendSpace2D:
AnimationNodeBlendSpace2D
=========================
**Inherits:** :ref:`AnimationRootNode<class_AnimationRootNode>` **<** :ref:`AnimationNode<class_AnimationNode>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
A set of :ref:`AnimationRootNode<class_AnimationRootNode>`\ s placed on 2D coordinates, crossfading between the three adjacent ones. Used by :ref:`AnimationTree<class_AnimationTree>`.
.. rst-class:: classref-introduction-group
Description
-----------
A resource used by :ref:`AnimationNodeBlendTree<class_AnimationNodeBlendTree>`.
\ **AnimationNodeBlendSpace2D** represents a virtual 2D space on which :ref:`AnimationRootNode<class_AnimationRootNode>`\ s are placed. Outputs the linear blend of the three adjacent animations using a :ref:`Vector2<class_Vector2>` weight. Adjacent in this context means the three :ref:`AnimationRootNode<class_AnimationRootNode>`\ s making up the triangle that contains the current value.
You can add vertices to the blend space with :ref:`add_blend_point()<class_AnimationNodeBlendSpace2D_method_add_blend_point>` and automatically triangulate it by setting :ref:`auto_triangles<class_AnimationNodeBlendSpace2D_property_auto_triangles>` to ``true``. Otherwise, use :ref:`add_triangle()<class_AnimationNodeBlendSpace2D_method_add_triangle>` and :ref:`remove_triangle()<class_AnimationNodeBlendSpace2D_method_remove_triangle>` to triangulate the blend space by hand.
.. rst-class:: classref-introduction-group
Tutorials
---------
- :doc:`Using AnimationTree <../tutorials/animation/animation_tree>`
- `Third Person Shooter (TPS) Demo <https://godotengine.org/asset-library/asset/2710>`__
.. rst-class:: classref-reftable-group
Properties
----------
.. table::
:widths: auto
+------------------------------------------------------------+--------------------------------------------------------------------------------+-----------------------+
| :ref:`bool<class_bool>` | :ref:`auto_triangles<class_AnimationNodeBlendSpace2D_property_auto_triangles>` | ``true`` |
+------------------------------------------------------------+--------------------------------------------------------------------------------+-----------------------+
| :ref:`BlendMode<enum_AnimationNodeBlendSpace2D_BlendMode>` | :ref:`blend_mode<class_AnimationNodeBlendSpace2D_property_blend_mode>` | ``0`` |
+------------------------------------------------------------+--------------------------------------------------------------------------------+-----------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`max_space<class_AnimationNodeBlendSpace2D_property_max_space>` | ``Vector2(1, 1)`` |
+------------------------------------------------------------+--------------------------------------------------------------------------------+-----------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`min_space<class_AnimationNodeBlendSpace2D_property_min_space>` | ``Vector2(-1, -1)`` |
+------------------------------------------------------------+--------------------------------------------------------------------------------+-----------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`snap<class_AnimationNodeBlendSpace2D_property_snap>` | ``Vector2(0.1, 0.1)`` |
+------------------------------------------------------------+--------------------------------------------------------------------------------+-----------------------+
| :ref:`bool<class_bool>` | :ref:`sync<class_AnimationNodeBlendSpace2D_property_sync>` | ``false`` |
+------------------------------------------------------------+--------------------------------------------------------------------------------+-----------------------+
| :ref:`String<class_String>` | :ref:`x_label<class_AnimationNodeBlendSpace2D_property_x_label>` | ``"x"`` |
+------------------------------------------------------------+--------------------------------------------------------------------------------+-----------------------+
| :ref:`String<class_String>` | :ref:`y_label<class_AnimationNodeBlendSpace2D_property_y_label>` | ``"y"`` |
+------------------------------------------------------------+--------------------------------------------------------------------------------+-----------------------+
.. rst-class:: classref-reftable-group
Methods
-------
.. table::
:widths: auto
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`add_blend_point<class_AnimationNodeBlendSpace2D_method_add_blend_point>`\ (\ node\: :ref:`AnimationRootNode<class_AnimationRootNode>`, pos\: :ref:`Vector2<class_Vector2>`, at_index\: :ref:`int<class_int>` = -1\ ) |
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`add_triangle<class_AnimationNodeBlendSpace2D_method_add_triangle>`\ (\ x\: :ref:`int<class_int>`, y\: :ref:`int<class_int>`, z\: :ref:`int<class_int>`, at_index\: :ref:`int<class_int>` = -1\ ) |
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`get_blend_point_count<class_AnimationNodeBlendSpace2D_method_get_blend_point_count>`\ (\ ) |const| |
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`AnimationRootNode<class_AnimationRootNode>` | :ref:`get_blend_point_node<class_AnimationNodeBlendSpace2D_method_get_blend_point_node>`\ (\ point\: :ref:`int<class_int>`\ ) |const| |
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`get_blend_point_position<class_AnimationNodeBlendSpace2D_method_get_blend_point_position>`\ (\ point\: :ref:`int<class_int>`\ ) |const| |
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`get_triangle_count<class_AnimationNodeBlendSpace2D_method_get_triangle_count>`\ (\ ) |const| |
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`get_triangle_point<class_AnimationNodeBlendSpace2D_method_get_triangle_point>`\ (\ triangle\: :ref:`int<class_int>`, point\: :ref:`int<class_int>`\ ) |
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`remove_blend_point<class_AnimationNodeBlendSpace2D_method_remove_blend_point>`\ (\ point\: :ref:`int<class_int>`\ ) |
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`remove_triangle<class_AnimationNodeBlendSpace2D_method_remove_triangle>`\ (\ triangle\: :ref:`int<class_int>`\ ) |
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`set_blend_point_node<class_AnimationNodeBlendSpace2D_method_set_blend_point_node>`\ (\ point\: :ref:`int<class_int>`, node\: :ref:`AnimationRootNode<class_AnimationRootNode>`\ ) |
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`set_blend_point_position<class_AnimationNodeBlendSpace2D_method_set_blend_point_position>`\ (\ point\: :ref:`int<class_int>`, pos\: :ref:`Vector2<class_Vector2>`\ ) |
+---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Signals
-------
.. _class_AnimationNodeBlendSpace2D_signal_triangles_updated:
.. rst-class:: classref-signal
**triangles_updated**\ (\ ) :ref:`🔗<class_AnimationNodeBlendSpace2D_signal_triangles_updated>`
Emitted every time the blend space's triangles are created, removed, or when one of their vertices changes position.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Enumerations
------------
.. _enum_AnimationNodeBlendSpace2D_BlendMode:
.. rst-class:: classref-enumeration
enum **BlendMode**: :ref:`🔗<enum_AnimationNodeBlendSpace2D_BlendMode>`
.. _class_AnimationNodeBlendSpace2D_constant_BLEND_MODE_INTERPOLATED:
.. rst-class:: classref-enumeration-constant
:ref:`BlendMode<enum_AnimationNodeBlendSpace2D_BlendMode>` **BLEND_MODE_INTERPOLATED** = ``0``
The interpolation between animations is linear.
.. _class_AnimationNodeBlendSpace2D_constant_BLEND_MODE_DISCRETE:
.. rst-class:: classref-enumeration-constant
:ref:`BlendMode<enum_AnimationNodeBlendSpace2D_BlendMode>` **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.
.. _class_AnimationNodeBlendSpace2D_constant_BLEND_MODE_DISCRETE_CARRY:
.. rst-class:: classref-enumeration-constant
:ref:`BlendMode<enum_AnimationNodeBlendSpace2D_BlendMode>` **BLEND_MODE_DISCRETE_CARRY** = ``2``
Similar to :ref:`BLEND_MODE_DISCRETE<class_AnimationNodeBlendSpace2D_constant_BLEND_MODE_DISCRETE>`, but starts the new animation at the last animation's playback position.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Property Descriptions
---------------------
.. _class_AnimationNodeBlendSpace2D_property_auto_triangles:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **auto_triangles** = ``true`` :ref:`🔗<class_AnimationNodeBlendSpace2D_property_auto_triangles>`
.. rst-class:: classref-property-setget
- |void| **set_auto_triangles**\ (\ value\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **get_auto_triangles**\ (\ )
If ``true``, the blend space is triangulated automatically. The mesh updates every time you add or remove points with :ref:`add_blend_point()<class_AnimationNodeBlendSpace2D_method_add_blend_point>` and :ref:`remove_blend_point()<class_AnimationNodeBlendSpace2D_method_remove_blend_point>`.
.. rst-class:: classref-item-separator
----
.. _class_AnimationNodeBlendSpace2D_property_blend_mode:
.. rst-class:: classref-property
:ref:`BlendMode<enum_AnimationNodeBlendSpace2D_BlendMode>` **blend_mode** = ``0`` :ref:`🔗<class_AnimationNodeBlendSpace2D_property_blend_mode>`
.. rst-class:: classref-property-setget
- |void| **set_blend_mode**\ (\ value\: :ref:`BlendMode<enum_AnimationNodeBlendSpace2D_BlendMode>`\ )
- :ref:`BlendMode<enum_AnimationNodeBlendSpace2D_BlendMode>` **get_blend_mode**\ (\ )
Controls the interpolation between animations.
.. rst-class:: classref-item-separator
----
.. _class_AnimationNodeBlendSpace2D_property_max_space:
.. rst-class:: classref-property
:ref:`Vector2<class_Vector2>` **max_space** = ``Vector2(1, 1)`` :ref:`🔗<class_AnimationNodeBlendSpace2D_property_max_space>`
.. rst-class:: classref-property-setget
- |void| **set_max_space**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
- :ref:`Vector2<class_Vector2>` **get_max_space**\ (\ )
The blend space's X and Y axes' upper limit for the points' position. See :ref:`add_blend_point()<class_AnimationNodeBlendSpace2D_method_add_blend_point>`.
.. rst-class:: classref-item-separator
----
.. _class_AnimationNodeBlendSpace2D_property_min_space:
.. rst-class:: classref-property
:ref:`Vector2<class_Vector2>` **min_space** = ``Vector2(-1, -1)`` :ref:`🔗<class_AnimationNodeBlendSpace2D_property_min_space>`
.. rst-class:: classref-property-setget
- |void| **set_min_space**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
- :ref:`Vector2<class_Vector2>` **get_min_space**\ (\ )
The blend space's X and Y axes' lower limit for the points' position. See :ref:`add_blend_point()<class_AnimationNodeBlendSpace2D_method_add_blend_point>`.
.. rst-class:: classref-item-separator
----
.. _class_AnimationNodeBlendSpace2D_property_snap:
.. rst-class:: classref-property
:ref:`Vector2<class_Vector2>` **snap** = ``Vector2(0.1, 0.1)`` :ref:`🔗<class_AnimationNodeBlendSpace2D_property_snap>`
.. rst-class:: classref-property-setget
- |void| **set_snap**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
- :ref:`Vector2<class_Vector2>` **get_snap**\ (\ )
Position increment to snap to when moving a point.
.. rst-class:: classref-item-separator
----
.. _class_AnimationNodeBlendSpace2D_property_sync:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **sync** = ``false`` :ref:`🔗<class_AnimationNodeBlendSpace2D_property_sync>`
.. rst-class:: classref-property-setget
- |void| **set_use_sync**\ (\ value\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **is_using_sync**\ (\ )
If ``false``, the blended animations' frame are stopped when the blend value is ``0``.
If ``true``, forcing the blended animations to advance frame.
.. rst-class:: classref-item-separator
----
.. _class_AnimationNodeBlendSpace2D_property_x_label:
.. rst-class:: classref-property
:ref:`String<class_String>` **x_label** = ``"x"`` :ref:`🔗<class_AnimationNodeBlendSpace2D_property_x_label>`
.. rst-class:: classref-property-setget
- |void| **set_x_label**\ (\ value\: :ref:`String<class_String>`\ )
- :ref:`String<class_String>` **get_x_label**\ (\ )
Name of the blend space's X axis.
.. rst-class:: classref-item-separator
----
.. _class_AnimationNodeBlendSpace2D_property_y_label:
.. rst-class:: classref-property
:ref:`String<class_String>` **y_label** = ``"y"`` :ref:`🔗<class_AnimationNodeBlendSpace2D_property_y_label>`
.. rst-class:: classref-property-setget
- |void| **set_y_label**\ (\ value\: :ref:`String<class_String>`\ )
- :ref:`String<class_String>` **get_y_label**\ (\ )
Name of the blend space's Y axis.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Method Descriptions
-------------------
.. _class_AnimationNodeBlendSpace2D_method_add_blend_point:
.. rst-class:: classref-method
|void| **add_blend_point**\ (\ node\: :ref:`AnimationRootNode<class_AnimationRootNode>`, pos\: :ref:`Vector2<class_Vector2>`, at_index\: :ref:`int<class_int>` = -1\ ) :ref:`🔗<class_AnimationNodeBlendSpace2D_method_add_blend_point>`
Adds a new point 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.
.. rst-class:: classref-item-separator
----
.. _class_AnimationNodeBlendSpace2D_method_add_triangle:
.. rst-class:: classref-method
|void| **add_triangle**\ (\ x\: :ref:`int<class_int>`, y\: :ref:`int<class_int>`, z\: :ref:`int<class_int>`, at_index\: :ref:`int<class_int>` = -1\ ) :ref:`🔗<class_AnimationNodeBlendSpace2D_method_add_triangle>`
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.
.. rst-class:: classref-item-separator
----
.. _class_AnimationNodeBlendSpace2D_method_get_blend_point_count:
.. rst-class:: classref-method
:ref:`int<class_int>` **get_blend_point_count**\ (\ ) |const| :ref:`🔗<class_AnimationNodeBlendSpace2D_method_get_blend_point_count>`
Returns the number of points in the blend space.
.. rst-class:: classref-item-separator
----
.. _class_AnimationNodeBlendSpace2D_method_get_blend_point_node:
.. rst-class:: classref-method
:ref:`AnimationRootNode<class_AnimationRootNode>` **get_blend_point_node**\ (\ point\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_AnimationNodeBlendSpace2D_method_get_blend_point_node>`
Returns the :ref:`AnimationRootNode<class_AnimationRootNode>` referenced by the point at index ``point``.
.. rst-class:: classref-item-separator
----
.. _class_AnimationNodeBlendSpace2D_method_get_blend_point_position:
.. rst-class:: classref-method
:ref:`Vector2<class_Vector2>` **get_blend_point_position**\ (\ point\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_AnimationNodeBlendSpace2D_method_get_blend_point_position>`
Returns the position of the point at index ``point``.
.. rst-class:: classref-item-separator
----
.. _class_AnimationNodeBlendSpace2D_method_get_triangle_count:
.. rst-class:: classref-method
:ref:`int<class_int>` **get_triangle_count**\ (\ ) |const| :ref:`🔗<class_AnimationNodeBlendSpace2D_method_get_triangle_count>`
Returns the number of triangles in the blend space.
.. rst-class:: classref-item-separator
----
.. _class_AnimationNodeBlendSpace2D_method_get_triangle_point:
.. rst-class:: classref-method
:ref:`int<class_int>` **get_triangle_point**\ (\ triangle\: :ref:`int<class_int>`, point\: :ref:`int<class_int>`\ ) :ref:`🔗<class_AnimationNodeBlendSpace2D_method_get_triangle_point>`
Returns the position of the point at index ``point`` in the triangle of index ``triangle``.
.. rst-class:: classref-item-separator
----
.. _class_AnimationNodeBlendSpace2D_method_remove_blend_point:
.. rst-class:: classref-method
|void| **remove_blend_point**\ (\ point\: :ref:`int<class_int>`\ ) :ref:`🔗<class_AnimationNodeBlendSpace2D_method_remove_blend_point>`
Removes the point at index ``point`` from the blend space.
.. rst-class:: classref-item-separator
----
.. _class_AnimationNodeBlendSpace2D_method_remove_triangle:
.. rst-class:: classref-method
|void| **remove_triangle**\ (\ triangle\: :ref:`int<class_int>`\ ) :ref:`🔗<class_AnimationNodeBlendSpace2D_method_remove_triangle>`
Removes the triangle at index ``triangle`` from the blend space.
.. rst-class:: classref-item-separator
----
.. _class_AnimationNodeBlendSpace2D_method_set_blend_point_node:
.. rst-class:: classref-method
|void| **set_blend_point_node**\ (\ point\: :ref:`int<class_int>`, node\: :ref:`AnimationRootNode<class_AnimationRootNode>`\ ) :ref:`🔗<class_AnimationNodeBlendSpace2D_method_set_blend_point_node>`
Changes the :ref:`AnimationNode<class_AnimationNode>` referenced by the point at index ``point``.
.. rst-class:: classref-item-separator
----
.. _class_AnimationNodeBlendSpace2D_method_set_blend_point_position:
.. rst-class:: classref-method
|void| **set_blend_point_position**\ (\ point\: :ref:`int<class_int>`, pos\: :ref:`Vector2<class_Vector2>`\ ) :ref:`🔗<class_AnimationNodeBlendSpace2D_method_set_blend_point_position>`
Updates the position of the point at index ``point`` in the blend space.
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
.. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
.. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
.. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
.. |void| replace:: :abbr:`void (No return value.)`