Files
godot-docs/classes/class_animationnodetransition.rst
2023-05-13 03:19:02 +00:00

240 lines
10 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/AnimationNodeTransition.xml.
.. _class_AnimationNodeTransition:
AnimationNodeTransition
=======================
**Inherits:** :ref:`AnimationNodeSync<class_AnimationNodeSync>` **<** :ref:`AnimationNode<class_AnimationNode>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
A transition within an :ref:`AnimationTree<class_AnimationTree>` connecting two :ref:`AnimationNode<class_AnimationNode>`\ s.
.. rst-class:: classref-introduction-group
Description
-----------
Simple state machine for cases which don't require a more advanced :ref:`AnimationNodeStateMachine<class_AnimationNodeStateMachine>`. Animations can be connected to the inputs and transition times can be specified.
After setting the request and changing the animation playback, the transition node automatically clears the request on the next process frame by setting its ``transition_request`` value to empty.
\ **Note:** When using a cross-fade, ``current_state`` and ``current_index`` change to the next state immediately after the cross-fade begins.
.. tabs::
.. code-tab:: gdscript
# Play child animation connected to "state_2" port.
animation_tree.set("parameters/Transition/transition_request", "state_2")
# Alternative syntax (same result as above).
animation_tree["parameters/Transition/transition_request"] = "state_2"
# Get current state name (read-only).
animation_tree.get("parameters/Transition/current_state")
# Alternative syntax (same result as above).
animation_tree["parameters/Transition/current_state"]
# Get current state index (read-only).
animation_tree.get("parameters/Transition/current_index"))
# Alternative syntax (same result as above).
animation_tree["parameters/Transition/current_index"]
.. code-tab:: csharp
// Play child animation connected to "state_2" port.
animationTree.Set("parameters/Transition/transition_request", "state_2");
// Get current state name (read-only).
animationTree.Get("parameters/Transition/current_state");
// Get current state index (read-only).
animationTree.Get("parameters/Transition/current_index");
.. rst-class:: classref-introduction-group
Tutorials
---------
- :doc:`Using AnimationTree <../tutorials/animation/animation_tree>`
- `3D Platformer Demo <https://godotengine.org/asset-library/asset/125>`__
- `Third Person Shooter Demo <https://godotengine.org/asset-library/asset/678>`__
.. rst-class:: classref-reftable-group
Properties
----------
.. table::
:widths: auto
+---------------------------+--------------------------------------------------------------------------------------------------+-----------+
| :ref:`bool<class_bool>` | :ref:`allow_transition_to_self<class_AnimationNodeTransition_property_allow_transition_to_self>` | ``false`` |
+---------------------------+--------------------------------------------------------------------------------------------------+-----------+
| :ref:`int<class_int>` | :ref:`input_count<class_AnimationNodeTransition_property_input_count>` | ``0`` |
+---------------------------+--------------------------------------------------------------------------------------------------+-----------+
| :ref:`Curve<class_Curve>` | :ref:`xfade_curve<class_AnimationNodeTransition_property_xfade_curve>` | |
+---------------------------+--------------------------------------------------------------------------------------------------+-----------+
| :ref:`float<class_float>` | :ref:`xfade_time<class_AnimationNodeTransition_property_xfade_time>` | ``0.0`` |
+---------------------------+--------------------------------------------------------------------------------------------------+-----------+
.. rst-class:: classref-reftable-group
Methods
-------
.. table::
:widths: auto
+-------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`is_input_reset<class_AnimationNodeTransition_method_is_input_reset>` **(** :ref:`int<class_int>` input **)** |const| |
+-------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`is_input_set_as_auto_advance<class_AnimationNodeTransition_method_is_input_set_as_auto_advance>` **(** :ref:`int<class_int>` input **)** |const| |
+-------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_input_as_auto_advance<class_AnimationNodeTransition_method_set_input_as_auto_advance>` **(** :ref:`int<class_int>` input, :ref:`bool<class_bool>` enable **)** |
+-------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_input_reset<class_AnimationNodeTransition_method_set_input_reset>` **(** :ref:`int<class_int>` input, :ref:`bool<class_bool>` enable **)** |
+-------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Property Descriptions
---------------------
.. _class_AnimationNodeTransition_property_allow_transition_to_self:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **allow_transition_to_self** = ``false``
.. rst-class:: classref-property-setget
- void **set_allow_transition_to_self** **(** :ref:`bool<class_bool>` value **)**
- :ref:`bool<class_bool>` **is_allow_transition_to_self** **(** **)**
If ``true``, allows transition to the self state. When the reset option is enabled in input, the animation is restarted. If ``false``, nothing happens on the transition to the self state.
.. rst-class:: classref-item-separator
----
.. _class_AnimationNodeTransition_property_input_count:
.. rst-class:: classref-property
:ref:`int<class_int>` **input_count** = ``0``
.. rst-class:: classref-property-setget
- void **set_input_count** **(** :ref:`int<class_int>` value **)**
- :ref:`int<class_int>` **get_input_count** **(** **)**
The number of enabled input ports for this node.
.. rst-class:: classref-item-separator
----
.. _class_AnimationNodeTransition_property_xfade_curve:
.. rst-class:: classref-property
:ref:`Curve<class_Curve>` **xfade_curve**
.. rst-class:: classref-property-setget
- void **set_xfade_curve** **(** :ref:`Curve<class_Curve>` value **)**
- :ref:`Curve<class_Curve>` **get_xfade_curve** **(** **)**
Determines how cross-fading between animations is eased. If empty, the transition will be linear.
.. rst-class:: classref-item-separator
----
.. _class_AnimationNodeTransition_property_xfade_time:
.. rst-class:: classref-property
:ref:`float<class_float>` **xfade_time** = ``0.0``
.. rst-class:: classref-property-setget
- void **set_xfade_time** **(** :ref:`float<class_float>` value **)**
- :ref:`float<class_float>` **get_xfade_time** **(** **)**
Cross-fading time (in seconds) between each animation connected to the inputs.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Method Descriptions
-------------------
.. _class_AnimationNodeTransition_method_is_input_reset:
.. rst-class:: classref-method
:ref:`bool<class_bool>` **is_input_reset** **(** :ref:`int<class_int>` input **)** |const|
Returns whether the animation restarts when the animation transitions from the other animation.
.. rst-class:: classref-item-separator
----
.. _class_AnimationNodeTransition_method_is_input_set_as_auto_advance:
.. rst-class:: classref-method
:ref:`bool<class_bool>` **is_input_set_as_auto_advance** **(** :ref:`int<class_int>` input **)** |const|
Returns ``true`` if auto-advance is enabled for the given ``input`` index.
.. rst-class:: classref-item-separator
----
.. _class_AnimationNodeTransition_method_set_input_as_auto_advance:
.. rst-class:: classref-method
void **set_input_as_auto_advance** **(** :ref:`int<class_int>` input, :ref:`bool<class_bool>` enable **)**
Enables or disables auto-advance for the given ``input`` index. If enabled, state changes to the next input after playing the animation once. If enabled for the last input state, it loops to the first.
.. rst-class:: classref-item-separator
----
.. _class_AnimationNodeTransition_method_set_input_reset:
.. rst-class:: classref-method
void **set_input_reset** **(** :ref:`int<class_int>` input, :ref:`bool<class_bool>` enable **)**
If ``true``, the destination animation is restarted when the animation transitions.
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
.. |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.)`