Get the exact name of a node in the scene tree and store it in a variable as a string

Godot Version

Godot 4.3

Question

I want to get the name of a node I have in the scene tree (which is another instanced scene) and store it in a variable for use elsewhere. Is there a way to get the name of a node in code. I am trying to do this because I have many of this instanced scene and I’ll need to delete specific instances that are named numerically. Really, I just need to know if there is a built in function to get the name of nodes.

Try self (or path to any node).name

2 Likes

Seems you ask about Node.get_path() but there are no reason to hold path, when you can hold node (reference to node really)

To be clear, it bad design. Godot have many mechanics to do this properly, if you not sure, use groups.

1 Like