[Godot 3.1] How to set a blend 2 node's blend amount which inside a state of state machine in Animation Tree?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By icqqq

Hello, everyone

Currently I am playing around with AnimationTree.

I have a state machine inside the AnimationTree, and in the state machine there is a state which is a AnimationNodeBlendTree.
Inside that AnimationNodeBlendTree, I have a blend 2 node which I want to set the blend amount through script.

So the setting is:
blend 2 node < state, which is a AnimationNodeBlendTree < state machine < AnimationTree

I have tried the following to set the blend amount but both failed:

$AnimationTree["parameters/state_machine_name/playback/state_name/blend2/blend_amount"] = 0.5

 $AnimationTree["parameters/state_machine_name/playback/state_name/blend_2/blend_amount"] = 0.5

 $AnimationTree["parameters/state_machine_name/state_name/blend2/blend_amount"] = 0.5

 $AnimationTree["parameters/state_machine_name/state_name/blend_2/blend_amount"] = 0.5

where state_machine_name is the state machine name and state_name is the state name.

So how can I set the blend amount?
Thanks!

:bust_in_silhouette: Reply From: Xrayez

Have you tried:

$AnimationTree.set("parameters/state_machine_name/state_name/blend_2/blend_amount",  0.5)

If you select the AnimationTree you’ll be able to see all parameters in one place in a visual way actually:

AnimationTree parameters

In order to not mess up with naming, you can rename newly added nodes in the AnimationNodeBlendTree instead of having to deal with default naming and the parameters will be updated accordingly:

Rename node

So in my case it just translated to:

$AnimationTree.set("parameters/0/walk/direction/current", p_walk_direction)`

I tried it but it takes no effect
Also, I have tried

print($AnimationTree.get("parameters/state_machine_name/state_name/blend_2/blend_amount"))

but it gives me null

icqqq | 2018-10-19 14:08

Oh well this could be an engine bug actually… you could try to test it out on a simpler configuration first (remove state machine) and see how it works for you.

Xrayez | 2018-10-19 14:13

ok it works in simpler configuration!
thx

icqqq | 2018-10-19 15:17

:bust_in_silhouette: Reply From: gamedevshirious

You can simply hover over the property to get exact property name
enter image description here