You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorials/animation/animation_tree.rst
+19-20Lines changed: 19 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,14 +12,13 @@ function calling, audio, and sub-animation tracks.
12
12
13
13
However, the support for blending those animations via ``AnimationPlayer`` is limited, as you can only set a fixed cross-fade transition time.
14
14
15
-
:ref:`AnimationTree <class_AnimationTree>` is a new node introduced in Godot 3.1 to deal with advanced transitions.
16
-
It replaces the ancient ``AnimationTreePlayer``, while adding a huge amount of features and flexibility.
15
+
:ref:`AnimationTree <class_AnimationTree>` is a node designed to deal with advanced transitions.
17
16
18
17
AnimationTree and AnimationPlayer
19
18
---------------------------------
20
19
21
20
Before starting, know that an ``AnimationTree`` node does not contain its own animations.
22
-
Instead, it uses animations contained in an ``AnimationPlayer`` node. You create, edit, or import your animations in an ``AnimationPlayer``
21
+
Instead, it uses animations contained in an ``AnimationPlayer`` node. You create, edit, or import your animations in an ``AnimationPlayer``
23
22
and then use an ``AnimationTree`` to control the playback.
24
23
25
24
``AnimationPlayer`` and ``AnimationTree`` can be used in both 2D and 3D scenes. When importing 3D scenes and their animations, you can use
@@ -38,8 +37,8 @@ and an ``AnimationTree`` node was created.
38
37
Creating a tree
39
38
---------------
40
39
41
-
To use an ``AnimationTree``, you have to set a root node. An animation root node is a class that contains and evaluates sub-nodes and outputs an animation.
42
-
There are 3 types of sub-nodes:
40
+
To use an ``AnimationTree``, you have to set a root node. An animation root node is a class that contains and evaluates sub-nodes and outputs an animation.
41
+
There are 3 types of sub-nodes:
43
42
44
43
1. Animation nodes, which reference an animation from the linked ``AnimationPlayer``.
45
44
2. Animation Root nodes, which are used to blend sub-nodes and can be nested.
@@ -59,7 +58,7 @@ Blend tree
59
58
----------
60
59
61
60
When you make an ``AnimationNodeBlendTree``, you get an empty 2d graph in the bottom panel, under the AnimationTree tab. It contains only an ``Output``
62
-
node by default.
61
+
node by default.
63
62
64
63
.. image:: img/animtree_emptyblendtree.webp
65
64
@@ -202,11 +201,11 @@ StateMachine
202
201
~~~~~~~~~~~~
203
202
204
203
When you make an ``AnimationNodeStateMachine``, you get an empty 2d graph in the bottom panel, under the AnimationTree tab. It contains a ``Start`` and ``End``
205
-
state by default.
204
+
state by default.
206
205
207
206
.. image:: img/animtree_emptystatemachine.webp
208
207
209
-
To add states, right click or use the **create new nodes** button, whose icon is a plus in a box. You can add animations, blendspaces, blendtrees, or even
208
+
To add states, right click or use the **create new nodes** button, whose icon is a plus in a box. You can add animations, blendspaces, blendtrees, or even
210
209
another StateMachine. To edit one of these more complex sub-nodes, click on the pencil icon on the right of the state. To return to the original StateMachine,
211
210
click **Root** on the top left of the panel.
212
211
@@ -219,7 +218,7 @@ There are 3 types of transitions:
219
218
220
219
.. image:: img/animtree_transitiontypes.png
221
220
222
-
* *Immediate*: Will switch to the next state immediately.
221
+
* *Immediate*: Will switch to the next state immediately.
223
222
* *Sync*: Will switch to the next state immediately, but will seek the new state to the playback position of the old state.
224
223
* *At End*: Will wait for the current state playback to end, then switch to the beginning of the next state animation.
225
224
@@ -240,12 +239,12 @@ Advance Condition and Advance Expression
240
239
The last 2 properties in a StateMachine transition are ``Advance Condition`` and ``Advance Expression.`` When the Advance Mode is set to *Auto*, these
241
240
determine if the transition will advance or not.
242
241
243
-
Advance Condition is a true/false check. You may put a custom variable name in the text field, and when the StateMachine reaches this transition,
244
-
it will check if your variable is *true*. If so, the transition continues. Note that the advance condition **only** checks if a variable is *true*,
242
+
Advance Condition is a true/false check. You may put a custom variable name in the text field, and when the StateMachine reaches this transition,
243
+
it will check if your variable is *true*. If so, the transition continues. Note that the advance condition **only** checks if a variable is *true*,
245
244
and it cannot check for falseness.
246
245
247
-
This gives the Advance Condition a very limited capability. If you wanted to make a transition back and forth based on one property, you would need to make
248
-
2 variables that have opposite values, and check if either of them are true. This is why, in Godot 4, the Advance Expression was added.
246
+
This gives the Advance Condition a very limited capability. If you wanted to make a transition back and forth based on one property, you would need to make
247
+
2 variables that have opposite values, and check if either of them are true. This is why, in Godot 4, the Advance Expression was added.
249
248
250
249
The Advance Expression works similar to the Advance Condition, but instead of checking if one variable is true, it evaluates any expression. An expression
251
250
is anything you could put in an ``if`` statement. These are all examples of expressions that would work in the Advance Expression:
@@ -308,14 +307,14 @@ is controlled to determine the blending:
308
307
309
308
.. image:: img/animtree_blendspace2d.gif
310
309
311
-
You may place these points anywhere on the graph by right clicking or using the **add point** button, whose icon is a pen and point.
310
+
You may place these points anywhere on the graph by right clicking or using the **add point** button, whose icon is a pen and point.
312
311
Wherever you place the points, the triangle between them will be generated automatically using Delaunay.
313
-
You may also control and label the ranges in X and Y.
312
+
You may also control and label the ranges in X and Y.
314
313
315
314
.. image:: img/animtree_blendspacepoints.gif
316
315
317
-
Finally, you may also change the blend mode. By default, blending happens by interpolating points inside the closest triangle. When dealing with 2D
318
-
animations (frame by frame), you may want to switch to *Discrete* mode. Alternatively, if you want to keep the current play position when switching
316
+
Finally, you may also change the blend mode. By default, blending happens by interpolating points inside the closest triangle. When dealing with 2D
317
+
animations (frame by frame), you may want to switch to *Discrete* mode. Alternatively, if you want to keep the current play position when switching
319
318
between discrete animations, there is a *Carry* mode. This mode can be changed in the *Blend* menu:
320
319
321
320
.. image:: img/animtree_blendmode.png
@@ -327,7 +326,7 @@ BlendSpace1D works just like BlendSpace2D, but in one dimension (a line). Triang
327
326
For better blending
328
327
-------------------
329
328
330
-
In Godot 4.0+, in order for the blending results to be deterministic (reproducible and always consistent),
329
+
For the blending results to be deterministic (reproducible and always consistent),
331
330
the blended property values must have a specific initial value.
332
331
For example, in the case of two animations to be blended, if one animation has a property track and the other does not,
333
332
the blended animation is calculated as if the latter animation had a property track with the initial value.
@@ -354,7 +353,7 @@ This problem can be solved by adding a Property track for Position as an initial
354
353
It is assumed to have only one frame and is not expected to be played back using the timeline.
355
354
356
355
Also keep in mind that the Rotation 3D tracks and the Property tracks for 2D rotation
357
-
with Interpolation Type set to Linear Angle or Cubic Angle will prevent rotations greater than 180 degrees
356
+
with Interpolation Type set to Linear Angle or Cubic Angle will prevent rotations greater than 180 degrees
358
357
from the initial value as blended animation.
359
358
360
359
This can be useful for Skeleton3Ds to prevent the bones penetrating the body when blending animations.
@@ -447,5 +446,5 @@ Then you can set or read them:
.. note:: Advance Expressions from a StateMachine will not be found under the parameters. This is because they are held in another script rather than the
449
+
.. note:: Advance Expressions from a StateMachine will not be found under the parameters. This is because they are held in another script rather than the
451
450
AnimationTree itself. Advance `Conditions` will be found under parameters.
0 commit comments