I personally do not know how to blend animations in Godot, but a potentially good reference is the Platformer3D demo. In the Platformer3D demo walk and idle animations are blended, along with firing animations.
EDIT: Just realized you've already looked at it...
I will do my best to explain how it is working (though as I said before, I haven't actually used animation blending myself):
You need to set up your scene tree so animations you want to blend are connected to each other. Using the Platformer3D as an example, you want to make sure your idle and running animations are connected to a Blend2
node. You can add a Blend2
node by pressing the plus icon on the top left window of the animation tree editor.
If you want to transition through animations you need to use a Transition
node.
You can rename the nodes to more descriptive names by right clicking them and selecting "rename".
Repeat this for all of the animations you want to blend. Make sure everything eventually connects to a Output
node.
Then in your code you need to use blend2_node_set_amount
to change the how much the animation is blended. Here is how it is done in the Platformer3D demo: get_node("AnimationTreePlayer").blend2_node_set_amount("walk", hspeed/max_speed)
walk
is the name of the blend2
node, and then you pass in a float ranging from 0
to 1
, where 0
will play the animation attached to socket a
, 1
will play the animation attached to socket b
, and any value in between blends the animations depending on how far they lean to either 0
or 1
. (A value of 0.5
will blend both animations equally)
To use transitions, you need to use transition_node_set_current
. The platformer3D code looks like this: transition_node_set_current("state", anim)
state
is the name of the transition node in the AnimationTree
, and anim
is a int. If anim
is 0
, then it will transition to the animation that is connected to socket 0
.