Godot Version
4.5
Question
Hello folks,
I’m not able to make manually created AnimationNodeStateMachineTransition work. The design I have is:
- Adding transitions for ALL animations in the AnimationNodeStateMachine;
- These transitions have advanced condition which named after the target animation;
- I will use my own state machine to set condition depends on state.
Here’s the code how I create transitions for ALL animations:
func _ready() -> void:
var node_sm = animation_tree.tree_root.get_node("StateMachine")
if node_sm is AnimationNodeStateMachine:
var node_list: Array[StringName] = node_sm.get_node_list()
for i in node_list.size():
var n1 = node_sm.get_node(node_list[i])
if n1 is AnimationNodeAnimation:
for j in node_list.size():
var n2 = node_sm.get_node(node_list[j])
if n2 is AnimationNodeAnimation and not i == j and not _has_transition(node_sm, node_list[i], node_list[j]):
var trans:= AnimationNodeStateMachineTransition.new()
trans.xfade_time = 0.2
trans.advance_mode = AnimationNodeStateMachineTransition.ADVANCE_MODE_AUTO
trans.advance_condition = str(node_list[j])
node_sm.add_transition(node_list[i], node_list[j], trans)
#node_sm.set_parameter(str(node_list[j]), false)
print("Transition added from %s to %s" % [node_list[i], node_list[j]])
The game is running but animation is not playing. I saw following errors in console:
E 0:00:00:894 get_parameter: Condition “!process_state->tree->property_parent_map\[node_state.base_path\].has(p_name)” is true. Returning: Variant()
<C++ Source> scene/animation/animation_tree.cpp:106 @ get_parameter()
If I uncomment set_parameter(str(node_list[j]), false). Anthor errors occurred before the same errors above indicating set_parameter is failed:
E 0:00:00:879 character.gd:63 @ _ready(): Parameter "process_state" is null.
<C++ Source> scene/animation/animation_tree.cpp:76 @ set_parameter()
<Stack Trace> character.gd:63 @ _ready()
I read the source cpp code (briefly as I’m not a cpp developer) but couldn’t dig out more information.
Does anyone have idea how this should be addressed?
Thanks!
