+1 vote

I know there is the function get_basename() on type String but if I call it on name, I get printed @Test@99. So the node's name of my instanced scene be "Test", how to get it? I want to do that because sometimes another Object with the same script is added.

Godot version 3.2.3.stable
in Engine by (380 points)

I know this question is tagged under gdscript, but I wanted the same thing in c# and your question helped me figure out the way to do it is using the Name property of a node object (ex: Node x; GD.Print(x.Name);)

2 Answers

0 votes

I had that problem also and I didn't find any option to call name or even custom class name. Filename worked for me, it is unique just like name and means resource path of your scene. It should do if You only need to identify nodes.

by (5,136 points)
0 votes
func node_name():
    return str(name.replace("@", "").replace(str(int(name)), ""))
by (4,972 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.