Why does get_node() return null?

func _ready() -> void:
    #removing self from World
	get_parent().remove_child.call_deferred(self)
	await get_tree().create_timer(1).timeout
    #returns null for some reason idk
	print(get_node("/root/World"))

why does the get_node() method, using the ABSOLUTE path to the World node, return null?

I believe get_node will always try to get a node relative to the node its currently being called from. So in this case, it’s trying to find a node under the current node, not from the root note.

You can either do:
get_tree().get_current_scene()
or
get_tree().get_root()

Then call get_node on one of those if you want to find something with an absolute path.

1 Like

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