Skip to content

Latest commit

 

History

History
521 lines (297 loc) · 42.6 KB

class_animationnode.rst

File metadata and controls

521 lines (297 loc) · 42.6 KB
github_url:hide

AnimationNode

Inherits: :ref:`Resource<class_Resource>` < :ref:`RefCounted<class_RefCounted>` < :ref:`Object<class_Object>`

Inherited By: :ref:`AnimationNodeExtension<class_AnimationNodeExtension>`, :ref:`AnimationNodeOutput<class_AnimationNodeOutput>`, :ref:`AnimationNodeSync<class_AnimationNodeSync>`, :ref:`AnimationNodeTimeScale<class_AnimationNodeTimeScale>`, :ref:`AnimationNodeTimeSeek<class_AnimationNodeTimeSeek>`, :ref:`AnimationRootNode<class_AnimationRootNode>`

Base class for :ref:`AnimationTree<class_AnimationTree>` nodes. Not related to scene nodes.

.. rst-class:: classref-introduction-group

Description

Base resource for :ref:`AnimationTree<class_AnimationTree>` nodes. In general, it's not used directly, but you can create custom ones with custom blending formulas.

Inherit this when creating animation nodes mainly for use in :ref:`AnimationNodeBlendTree<class_AnimationNodeBlendTree>`, otherwise :ref:`AnimationRootNode<class_AnimationRootNode>` should be used instead.

You can access the time information as read-only parameter which is processed and stored in the previous frame for all nodes except :ref:`AnimationNodeOutput<class_AnimationNodeOutput>`.

Note: If multiple inputs exist in the AnimationNode, which time information takes precedence depends on the type of AnimationNode.

var current_length = $AnimationTree[parameters/AnimationNodeName/current_length]
var current_position = $AnimationTree[parameters/AnimationNodeName/current_position]
var current_delta = $AnimationTree[parameters/AnimationNodeName/current_delta]
.. rst-class:: classref-introduction-group

Tutorials

.. rst-class:: classref-reftable-group

Properties

:ref:`bool<class_bool>` :ref:`filter_enabled<class_AnimationNode_property_filter_enabled>`
.. rst-class:: classref-reftable-group

Methods

:ref:`String<class_String>` :ref:`_get_caption<class_AnimationNode_private_method__get_caption>`() |virtual| |const|
:ref:`AnimationNode<class_AnimationNode>` :ref:`_get_child_by_name<class_AnimationNode_private_method__get_child_by_name>`(name: :ref:`StringName<class_StringName>`) |virtual| |const|
:ref:`Dictionary<class_Dictionary>` :ref:`_get_child_nodes<class_AnimationNode_private_method__get_child_nodes>`() |virtual| |const|
:ref:`Variant<class_Variant>` :ref:`_get_parameter_default_value<class_AnimationNode_private_method__get_parameter_default_value>`(parameter: :ref:`StringName<class_StringName>`) |virtual| |const|
:ref:`Array<class_Array>` :ref:`_get_parameter_list<class_AnimationNode_private_method__get_parameter_list>`() |virtual| |const|
:ref:`bool<class_bool>` :ref:`_has_filter<class_AnimationNode_private_method__has_filter>`() |virtual| |const|
:ref:`bool<class_bool>` :ref:`_is_parameter_read_only<class_AnimationNode_private_method__is_parameter_read_only>`(parameter: :ref:`StringName<class_StringName>`) |virtual| |const|
:ref:`float<class_float>` :ref:`_process<class_AnimationNode_private_method__process>`(time: :ref:`float<class_float>`, seek: :ref:`bool<class_bool>`, is_external_seeking: :ref:`bool<class_bool>`, test_only: :ref:`bool<class_bool>`) |virtual|
:ref:`bool<class_bool>` :ref:`add_input<class_AnimationNode_method_add_input>`(name: :ref:`String<class_String>`)
|void| :ref:`blend_animation<class_AnimationNode_method_blend_animation>`(animation: :ref:`StringName<class_StringName>`, time: :ref:`float<class_float>`, delta: :ref:`float<class_float>`, seeked: :ref:`bool<class_bool>`, is_external_seeking: :ref:`bool<class_bool>`, blend: :ref:`float<class_float>`, looped_flag: :ref:`LoopedFlag<enum_Animation_LoopedFlag>` = 0)
:ref:`float<class_float>` :ref:`blend_input<class_AnimationNode_method_blend_input>`(input_index: :ref:`int<class_int>`, time: :ref:`float<class_float>`, seek: :ref:`bool<class_bool>`, is_external_seeking: :ref:`bool<class_bool>`, blend: :ref:`float<class_float>`, filter: :ref:`FilterAction<enum_AnimationNode_FilterAction>` = 0, sync: :ref:`bool<class_bool>` = true, test_only: :ref:`bool<class_bool>` = false)
:ref:`float<class_float>` :ref:`blend_node<class_AnimationNode_method_blend_node>`(name: :ref:`StringName<class_StringName>`, node: :ref:`AnimationNode<class_AnimationNode>`, time: :ref:`float<class_float>`, seek: :ref:`bool<class_bool>`, is_external_seeking: :ref:`bool<class_bool>`, blend: :ref:`float<class_float>`, filter: :ref:`FilterAction<enum_AnimationNode_FilterAction>` = 0, sync: :ref:`bool<class_bool>` = true, test_only: :ref:`bool<class_bool>` = false)
:ref:`int<class_int>` :ref:`find_input<class_AnimationNode_method_find_input>`(name: :ref:`String<class_String>`) |const|
:ref:`int<class_int>` :ref:`get_input_count<class_AnimationNode_method_get_input_count>`() |const|
:ref:`String<class_String>` :ref:`get_input_name<class_AnimationNode_method_get_input_name>`(input: :ref:`int<class_int>`) |const|
:ref:`Variant<class_Variant>` :ref:`get_parameter<class_AnimationNode_method_get_parameter>`(name: :ref:`StringName<class_StringName>`) |const|
:ref:`int<class_int>` :ref:`get_processing_animation_tree_instance_id<class_AnimationNode_method_get_processing_animation_tree_instance_id>`() |const|
:ref:`bool<class_bool>` :ref:`is_path_filtered<class_AnimationNode_method_is_path_filtered>`(path: :ref:`NodePath<class_NodePath>`) |const|
:ref:`bool<class_bool>` :ref:`is_process_testing<class_AnimationNode_method_is_process_testing>`() |const|
|void| :ref:`remove_input<class_AnimationNode_method_remove_input>`(index: :ref:`int<class_int>`)
|void| :ref:`set_filter_path<class_AnimationNode_method_set_filter_path>`(path: :ref:`NodePath<class_NodePath>`, enable: :ref:`bool<class_bool>`)
:ref:`bool<class_bool>` :ref:`set_input_name<class_AnimationNode_method_set_input_name>`(input: :ref:`int<class_int>`, name: :ref:`String<class_String>`)
|void| :ref:`set_parameter<class_AnimationNode_method_set_parameter>`(name: :ref:`StringName<class_StringName>`, value: :ref:`Variant<class_Variant>`)
.. rst-class:: classref-section-separator


.. rst-class:: classref-descriptions-group

Signals

.. rst-class:: classref-signal

animation_node_removed(object_id: :ref:`int<class_int>`, name: :ref:`String<class_String>`) :ref:`🔗<class_AnimationNode_signal_animation_node_removed>`

Emitted by nodes that inherit from this class and that have an internal tree when one of their animation nodes removes. The animation nodes that emit this signal are :ref:`AnimationNodeBlendSpace1D<class_AnimationNodeBlendSpace1D>`, :ref:`AnimationNodeBlendSpace2D<class_AnimationNodeBlendSpace2D>`, :ref:`AnimationNodeStateMachine<class_AnimationNodeStateMachine>`, and :ref:`AnimationNodeBlendTree<class_AnimationNodeBlendTree>`.

.. rst-class:: classref-item-separator


.. rst-class:: classref-signal

animation_node_renamed(object_id: :ref:`int<class_int>`, old_name: :ref:`String<class_String>`, new_name: :ref:`String<class_String>`) :ref:`🔗<class_AnimationNode_signal_animation_node_renamed>`

Emitted by nodes that inherit from this class and that have an internal tree when one of their animation node names changes. The animation nodes that emit this signal are :ref:`AnimationNodeBlendSpace1D<class_AnimationNodeBlendSpace1D>`, :ref:`AnimationNodeBlendSpace2D<class_AnimationNodeBlendSpace2D>`, :ref:`AnimationNodeStateMachine<class_AnimationNodeStateMachine>`, and :ref:`AnimationNodeBlendTree<class_AnimationNodeBlendTree>`.

.. rst-class:: classref-item-separator


.. rst-class:: classref-signal

tree_changed() :ref:`🔗<class_AnimationNode_signal_tree_changed>`

Emitted by nodes that inherit from this class and that have an internal tree when one of their animation nodes changes. The animation nodes that emit this signal are :ref:`AnimationNodeBlendSpace1D<class_AnimationNodeBlendSpace1D>`, :ref:`AnimationNodeBlendSpace2D<class_AnimationNodeBlendSpace2D>`, :ref:`AnimationNodeStateMachine<class_AnimationNodeStateMachine>`, :ref:`AnimationNodeBlendTree<class_AnimationNodeBlendTree>` and :ref:`AnimationNodeTransition<class_AnimationNodeTransition>`.

.. rst-class:: classref-section-separator


.. rst-class:: classref-descriptions-group

Enumerations

.. rst-class:: classref-enumeration

enum FilterAction: :ref:`🔗<enum_AnimationNode_FilterAction>`

.. rst-class:: classref-enumeration-constant

:ref:`FilterAction<enum_AnimationNode_FilterAction>` FILTER_IGNORE = 0

Do not use filtering.

.. rst-class:: classref-enumeration-constant

:ref:`FilterAction<enum_AnimationNode_FilterAction>` FILTER_PASS = 1

Paths matching the filter will be allowed to pass.

.. rst-class:: classref-enumeration-constant

:ref:`FilterAction<enum_AnimationNode_FilterAction>` FILTER_STOP = 2

Paths matching the filter will be discarded.

.. rst-class:: classref-enumeration-constant

:ref:`FilterAction<enum_AnimationNode_FilterAction>` FILTER_BLEND = 3

Paths matching the filter will be blended (by the blend value).

.. rst-class:: classref-section-separator


.. rst-class:: classref-descriptions-group

Property Descriptions

.. rst-class:: classref-property

:ref:`bool<class_bool>` filter_enabled :ref:`🔗<class_AnimationNode_property_filter_enabled>`

.. rst-class:: classref-property-setget

If true, filtering is enabled.

.. rst-class:: classref-section-separator


.. rst-class:: classref-descriptions-group

Method Descriptions

.. rst-class:: classref-method

:ref:`String<class_String>` _get_caption() |virtual| |const| :ref:`🔗<class_AnimationNode_private_method__get_caption>`

When inheriting from :ref:`AnimationRootNode<class_AnimationRootNode>`, implement this virtual method to override the text caption for this animation node.

.. rst-class:: classref-item-separator


.. rst-class:: classref-method

:ref:`AnimationNode<class_AnimationNode>` _get_child_by_name(name: :ref:`StringName<class_StringName>`) |virtual| |const| :ref:`🔗<class_AnimationNode_private_method__get_child_by_name>`

When inheriting from :ref:`AnimationRootNode<class_AnimationRootNode>`, implement this virtual method to return a child animation node by its name.

.. rst-class:: classref-item-separator


.. rst-class:: classref-method

:ref:`Dictionary<class_Dictionary>` _get_child_nodes() |virtual| |const| :ref:`🔗<class_AnimationNode_private_method__get_child_nodes>`

When inheriting from :ref:`AnimationRootNode<class_AnimationRootNode>`, implement this virtual method to return all child animation nodes in order as a name: node dictionary.

.. rst-class:: classref-item-separator


.. rst-class:: classref-method

:ref:`Variant<class_Variant>` _get_parameter_default_value(parameter: :ref:`StringName<class_StringName>`) |virtual| |const| :ref:`🔗<class_AnimationNode_private_method__get_parameter_default_value>`

When inheriting from :ref:`AnimationRootNode<class_AnimationRootNode>`, implement this virtual method to return the default value of a parameter. Parameters are custom local memory used for your animation nodes, given a resource can be reused in multiple trees.

.. rst-class:: classref-item-separator


.. rst-class:: classref-method

:ref:`Array<class_Array>` _get_parameter_list() |virtual| |const| :ref:`🔗<class_AnimationNode_private_method__get_parameter_list>`

When inheriting from :ref:`AnimationRootNode<class_AnimationRootNode>`, implement this virtual method to return a list of the properties on this animation node. Parameters are custom local memory used for your animation nodes, given a resource can be reused in multiple trees. Format is similar to :ref:`Object.get_property_list()<class_Object_method_get_property_list>`.

.. rst-class:: classref-item-separator


.. rst-class:: classref-method

:ref:`bool<class_bool>` _has_filter() |virtual| |const| :ref:`🔗<class_AnimationNode_private_method__has_filter>`

When inheriting from :ref:`AnimationRootNode<class_AnimationRootNode>`, implement this virtual method to return whether the blend tree editor should display filter editing on this animation node.

.. rst-class:: classref-item-separator


.. rst-class:: classref-method

:ref:`bool<class_bool>` _is_parameter_read_only(parameter: :ref:`StringName<class_StringName>`) |virtual| |const| :ref:`🔗<class_AnimationNode_private_method__is_parameter_read_only>`

When inheriting from :ref:`AnimationRootNode<class_AnimationRootNode>`, implement this virtual method to return whether the parameter is read-only. Parameters are custom local memory used for your animation nodes, given a resource can be reused in multiple trees.

.. rst-class:: classref-item-separator


.. rst-class:: classref-method

:ref:`float<class_float>` _process(time: :ref:`float<class_float>`, seek: :ref:`bool<class_bool>`, is_external_seeking: :ref:`bool<class_bool>`, test_only: :ref:`bool<class_bool>`) |virtual| :ref:`🔗<class_AnimationNode_private_method__process>`

Deprecated: Currently this is mostly useless as there is a lack of many APIs to extend AnimationNode by GDScript. It is planned that a more flexible API using structures will be provided in the future.

When inheriting from :ref:`AnimationRootNode<class_AnimationRootNode>`, implement this virtual method to run some code when this animation node is processed. The time parameter is a relative delta, unless seek is true, in which case it is absolute.

Here, call the :ref:`blend_input()<class_AnimationNode_method_blend_input>`, :ref:`blend_node()<class_AnimationNode_method_blend_node>` or :ref:`blend_animation()<class_AnimationNode_method_blend_animation>` functions. You can also use :ref:`get_parameter()<class_AnimationNode_method_get_parameter>` and :ref:`set_parameter()<class_AnimationNode_method_set_parameter>` to modify local memory.

This function should return the delta.

.. rst-class:: classref-item-separator


.. rst-class:: classref-method

:ref:`bool<class_bool>` add_input(name: :ref:`String<class_String>`) :ref:`🔗<class_AnimationNode_method_add_input>`

Adds an input to the animation node. This is only useful for animation nodes created for use in an :ref:`AnimationNodeBlendTree<class_AnimationNodeBlendTree>`. If the addition fails, returns false.

.. rst-class:: classref-item-separator


.. rst-class:: classref-method

|void| blend_animation(animation: :ref:`StringName<class_StringName>`, time: :ref:`float<class_float>`, delta: :ref:`float<class_float>`, seeked: :ref:`bool<class_bool>`, is_external_seeking: :ref:`bool<class_bool>`, blend: :ref:`float<class_float>`, looped_flag: :ref:`LoopedFlag<enum_Animation_LoopedFlag>` = 0) :ref:`🔗<class_AnimationNode_method_blend_animation>`

Blend an animation by blend amount (name must be valid in the linked :ref:`AnimationPlayer<class_AnimationPlayer>`). A time and delta may be passed, as well as whether seeked happened.

A looped_flag is used by internal processing immediately after the loop. See also :ref:`LoopedFlag<enum_Animation_LoopedFlag>`.

.. rst-class:: classref-item-separator


.. rst-class:: classref-method

:ref:`float<class_float>` blend_input(input_index: :ref:`int<class_int>`, time: :ref:`float<class_float>`, seek: :ref:`bool<class_bool>`, is_external_seeking: :ref:`bool<class_bool>`, blend: :ref:`float<class_float>`, filter: :ref:`FilterAction<enum_AnimationNode_FilterAction>` = 0, sync: :ref:`bool<class_bool>` = true, test_only: :ref:`bool<class_bool>` = false) :ref:`🔗<class_AnimationNode_method_blend_input>`

Blend an input. This is only useful for animation nodes created for an :ref:`AnimationNodeBlendTree<class_AnimationNodeBlendTree>`. The time parameter is a relative delta, unless seek is true, in which case it is absolute. A filter mode may be optionally passed (see :ref:`FilterAction<enum_AnimationNode_FilterAction>` for options).

.. rst-class:: classref-item-separator


.. rst-class:: classref-method

:ref:`float<class_float>` blend_node(name: :ref:`StringName<class_StringName>`, node: :ref:`AnimationNode<class_AnimationNode>`, time: :ref:`float<class_float>`, seek: :ref:`bool<class_bool>`, is_external_seeking: :ref:`bool<class_bool>`, blend: :ref:`float<class_float>`, filter: :ref:`FilterAction<enum_AnimationNode_FilterAction>` = 0, sync: :ref:`bool<class_bool>` = true, test_only: :ref:`bool<class_bool>` = false) :ref:`🔗<class_AnimationNode_method_blend_node>`

Blend another animation node (in case this animation node contains child animation nodes). This function is only useful if you inherit from :ref:`AnimationRootNode<class_AnimationRootNode>` instead, otherwise editors will not display your animation node for addition.

.. rst-class:: classref-item-separator


.. rst-class:: classref-method

:ref:`int<class_int>` find_input(name: :ref:`String<class_String>`) |const| :ref:`🔗<class_AnimationNode_method_find_input>`

Returns the input index which corresponds to name. If not found, returns -1.

.. rst-class:: classref-item-separator


.. rst-class:: classref-method

:ref:`int<class_int>` get_input_count() |const| :ref:`🔗<class_AnimationNode_method_get_input_count>`

Amount of inputs in this animation node, only useful for animation nodes that go into :ref:`AnimationNodeBlendTree<class_AnimationNodeBlendTree>`.

.. rst-class:: classref-item-separator


.. rst-class:: classref-method

:ref:`String<class_String>` get_input_name(input: :ref:`int<class_int>`) |const| :ref:`🔗<class_AnimationNode_method_get_input_name>`

Gets the name of an input by index.

.. rst-class:: classref-item-separator


.. rst-class:: classref-method

:ref:`Variant<class_Variant>` get_parameter(name: :ref:`StringName<class_StringName>`) |const| :ref:`🔗<class_AnimationNode_method_get_parameter>`

Gets the value of a parameter. Parameters are custom local memory used for your animation nodes, given a resource can be reused in multiple trees.

.. rst-class:: classref-item-separator


.. rst-class:: classref-method

:ref:`int<class_int>` get_processing_animation_tree_instance_id() |const| :ref:`🔗<class_AnimationNode_method_get_processing_animation_tree_instance_id>`

Returns the object id of the :ref:`AnimationTree<class_AnimationTree>` that owns this node.

Note: This method should only be called from within the :ref:`AnimationNodeExtension._process_animation_node()<class_AnimationNodeExtension_private_method__process_animation_node>` method, and will return an invalid id otherwise.

.. rst-class:: classref-item-separator


.. rst-class:: classref-method

:ref:`bool<class_bool>` is_path_filtered(path: :ref:`NodePath<class_NodePath>`) |const| :ref:`🔗<class_AnimationNode_method_is_path_filtered>`

Returns true if the given path is filtered.

.. rst-class:: classref-item-separator


.. rst-class:: classref-method

:ref:`bool<class_bool>` is_process_testing() |const| :ref:`🔗<class_AnimationNode_method_is_process_testing>`

Returns true if this animation node is being processed in test-only mode.

.. rst-class:: classref-item-separator


.. rst-class:: classref-method

|void| remove_input(index: :ref:`int<class_int>`) :ref:`🔗<class_AnimationNode_method_remove_input>`

Removes an input, call this only when inactive.

.. rst-class:: classref-item-separator


.. rst-class:: classref-method

|void| set_filter_path(path: :ref:`NodePath<class_NodePath>`, enable: :ref:`bool<class_bool>`) :ref:`🔗<class_AnimationNode_method_set_filter_path>`

Adds or removes a path for the filter.

.. rst-class:: classref-item-separator


.. rst-class:: classref-method

:ref:`bool<class_bool>` set_input_name(input: :ref:`int<class_int>`, name: :ref:`String<class_String>`) :ref:`🔗<class_AnimationNode_method_set_input_name>`

Sets the name of the input at the given input index. If the setting fails, returns false.

.. rst-class:: classref-item-separator


.. rst-class:: classref-method

|void| set_parameter(name: :ref:`StringName<class_StringName>`, value: :ref:`Variant<class_Variant>`) :ref:`🔗<class_AnimationNode_method_set_parameter>`

Sets a custom parameter. These are used as local memory, because resources can be reused across the tree or scenes.