Unique name acess problem

Godot Version

4.3 and 4.2.2

Question

is it a bug that i can not access my Map node by its unique from my Statemaschiene or is it intenional?(%Map gives an null objekt) if so whats a good way i get access to functions of my Map ?

This is a limitation of scene unique names, check docs there: Scene Unique Nodes — Godot Engine (stable) documentation in English


I recommend to you use groups instead, with groups you can acess any node from anywhere (the nodes just need to be inside the tree):

# In your Map script
func _ready():
	add_to_group("map")
# In your state_machine script when you need to get the Map node:
var my_map = get_tree().get_first_node_in_group("map")

2 Likes

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