#How do you control sliders in Add2 or Blend2 using scripts?
1 messages · Page 1 of 1 (latest)
I find it's also useful to make a wrapper method or property around these because it's quite unwieldy
# method style
func set_eye(blend: float) -> void:
animation_tree.set(&"parameters/eye_blend/blend_amount", blend)
# property style
var eye: float:
get:
return eye
set(value):
eye = value
animation_tree.set(&"parameters/eye_blend/blend_amount", eye)
func _ready() -> void:
# set initial animation blend states
eye = 1.0
I somehow overlooked that section, but even with that parameter I'm still having no luck.
I'm trying something like this.
var add2_node_name = "22"
var add2_node = AnimationNodeAdd2.new()
tree_root.add_node(add2_node_name, add2_node, Vector2(100, 100))
tree_root.connect_node(add2_node_name, 0, reset_node_name)
tree_root.connect_node(add2_node_name, 1, animation_node_name)
var parameter_name = "parameters/" + add2_node_name + "/add_amount"
tree_root.set(parameter_name, 1.0)
print(tree_root.get(parameter_name))
The code is running (I can tell because the tree is getting built), but the Add Amount stays at 0.0 and the print sends <null> to the output
(Forgot to use reply earlier)
I've simplified my example even further, and neither is working. Both nodes get added, both nodes stay at 0.0, both nodes return <null>
tree_root.add_node(&"b22", AnimationNodeBlend2.new(), Vector2(-200, -200))
tree_root.set(&"parameters/b22/blend_amount", 1.0)
print(tree_root.get(&"parameters/b22/blend_amount"))
tree_root.add_node(&"a22", AnimationNodeAdd2.new(), Vector2(-300, -300))
tree_root.set(&"parameters/a22/add_amount", 1.0)
print(tree_root.get(&"parameters/a22/add_amount"))
There's got to be something simple I'm missing, I just don't see what it is
Figured it out... I was calling the functions from a class that extended AnimationTree, so I didn't need to be calling tree_root.set(...) I just needed to call set(...)