#How do you control sliders in Add2 or Blend2 using scripts?

1 messages · Page 1 of 1 (latest)

steady sleet
#

I've been working with AnimationNodes and I can't seem to find how to programmatically set this slider - or even what the slider is officially called. I'm not even sure if it's the same name for both Add2 and Blend2 or if it's a different name for each.

distant perch
# steady sleet I've been working with AnimationNodes and I can't seem to find how to programmat...

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
steady sleet
#

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

steady sleet
# distant perch I find it's also useful to make a wrapper method or property around these becaus...

(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(...)