get_node function not getting node from resource path

Godot Version

4.3

Question

This is my first time posting on the forums, however I am not completely inexperienced with godot and have been using it for a while (like a year on and off). I am not very aware of most technical and complicated programming things though so please bear with me if I am missing something obvious here.

I have followed this tutorial and have been unable to get any responses in the comment section regarding this issue after about a month of nobody responding, so I figured the forums would be of more help. I have gone over the video many times making sure that everything is as it should be and I see no issue.

The custom function_resource function is having the issue where it is unable to get the node with the get_node function even though it is in the scene tree and crashing the game after running. I have scoured the deepest darkest depths of the video’s comment section and nobody else seems to have this issue.

Here is the function that is being a problem:

func _function_resource(i: DialogueFunction) -> void:
	var target_node = get_node(i.target_path)
	if target_node.has_method(i.function_name):
		if i.function_arguments.size() == 0:
			target_node.call(i.function_name)
		else:
			target_node.callv(i.function_name, i.function_arguments)
	
	if i.wait_for_signal_to_continue:
		var signal_name = i.wait_for_signal_to_continue
		if target_node.has_signal(signal_name):
			var signal_state = { "done": false }
			var callable = func(_args): signal_state.done = true
			target_node.connect(signal_name, callable, CONNECT_ONE_SHOT)
			while not signal_state.done:
				await get_tree().process_frame
	
	current_dialogue_item += 1
	next_item = true

In the DialogueFunction resource target_path is declared to be a NodePath. I have printed out the target_path before the line that crashes the game and it is the correct path for the node, but for some reason it doesn’t work in the get_node function.

The path for the node I am trying to get is “y sorted things/DuckKnight/AnimationPlayer”

This is the error I am getting that is causing the game to crash:
Screenshot 2025-10-31 174446

Here is what my scene tree looks like:


the node with the script that has the function_resource function is instantiated as a child of the canvas layer node

Really hoping that this isn’t just me being stupid or overlooking something,
thanks for taking the time to hear my plea for help.

You’re using the relative node path ../y sorted thing/blah, then calling get_node with that from a child of the canvas layer node. The .. part will get you from that child to the canvas layer node, then the y sorted part will get you… nowhere.

2 Likes

Thanks so much, that was all I needed I think!

Maybe a little bit of a not very good solution, but I just changed this inside of the function_resource function:

func _function_resource(i: DialogueFunction) -> void:
	var target_node = get_node("../" + str(i.target_path))