Nodepaths in Dictonary

Godot 4.3

I might have a brain fart here but I seem to be incapable to draw a node path from a dictionary.

In my code I use a dictionary to define the spawn position of a node.

spawner[spawn_position].add_child(spawn)

and I can’t get Godot to recognize it as a node path.

If I do it static, for example:

%EnemySpawn1.add_child(spawn)

then it works without a problem.

I put the node paths as strings into the dictionary and that seems to be the problem but how else would I do this? Or how can I transform the string into a valid node path?

Thanks for the help.

You could use the stored string like this

get_node(storedString)

Or you could use

NodePath("path_to_node")

In this case, you’ll also need to use

get_node(nodePath)

to reference the node

1 Like

Thx, get_node(Nodepath(…)) solved it. Now I know how to do this.

1 Like