Can't find node on AnimationStateMachinePlayback.start()

Godot Version

4.2.2

Question

I’m trying to play an attack animation according to the players held weapon. I have two weapons named “Fists” and “Test” that have their respective nested state machines. The code calls start() on the state machine with the weapon’s name as an argument.

“Blade” is the newest weapon implemented here, which is relevant because of reasons below.

var attack_state_machine : AnimationNodeStateMachinePlayback =     self["parameters/ATTACK_tree/playback"]

func _on_player_action_attack():
    if attack_status == false && current_equipment_info != null:
		_change_attack_status(true)
		attack_state_machine.start(current_equipment_info.name)
		if combo != current_equipment_info.max_combo:
			combo +=1
		else:
			combo =0
		
		if attack_blend_tween:
			attack_blend_tween.kill()
		attack_blend_tween = create_tween()
		attack_blend_tween.tween_property(
			animation_tree, "parameters/ATTACK_blend/blend_amount",1,0.05
		)

This works as expected.

But the animation only ever plays if the weapon’s name is “Fists” or “Test”

Renaming either of the two nested state machines and the weapon name to match OR creating a new state machine with a matching weapon name will throw this error:

get_node: Weapon is not found current state.
<C++ Error>    Condition "!states.has(p\_name)" is true. Returning: Ref<AnimationNode>()
<C++ Source>   scene/animation/animation\_node\_state\_machine.cpp:1348 @ get\_node()
_process: No such node: 'Weapon'
<C++ Error>    Method/function failed. Returning: 0
<C++ Source>   scene/animation/animation_node_state_machine.cpp:735 @ _process()

I’ve ensured that the weapon names match with the state machines a dozen times now.

So far, I’ve tried:
-Deleting and recreating the StateMachines manually
-Deleting the AnimationTree node and re-loading the Tree Root through its saved resource
-Deleting the editor cache
-Using travel() instead of start()

Figured it out. The player character placed in the main scene was not updating as I edited the AnimationTree. Removed it and then replaced it.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.