I have an AnimationNodeBlendTree object which I created programmatically, and an output node (AnimationNodeOutput object) that was created along with this AnimationNodeBlendTree object.
How do I get a node that is connected to the input of this output node, if it exists?
Ah, right. I didn’t test it and the documentation wasn’t clear
It’s possible to get the connections but it’s not exposed directly.
extends Node
@onready var animation_tree: AnimationTree = $AnimationTree
func _ready() -> void:
var tree = animation_tree.tree_root as AnimationNodeBlendTree
var connections = tree.get("node_connections")
for i in range(0, connections.size(), 3):
var target = connections[i + 0]
var input_idx = connections[i + 1]
var source = connections[i + 2]
print("Node %s is connected to %s in port %s" % [source, target, input_idx])