This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

I created a CustomNode as a plugin, and when I add it to the scene tree, there it is, for me to select. But what I really want to do is add it to my scene tree from code. So, when I do CustomNode.new() I get an error, "The identifier "CustomNode" isn't declared in the current scope." I can do Sprite.new() etc, but it won't let me do my CustomNode.new()

Godot version 3.4.2
in Engine by (24 points)

2 Answers

0 votes
Best answer

Thank you for responding. Yes, I did activate the plugin and it appears. But I actually found something that seemed to fix it. All I had to do was put this line in my customnode.gd file. The line is: classname CustomNode. This wasn't in the guides and tutorials I was using, I saw class_name class for defining classes and thought it might work for this custom node as well and it worked!

Now the class is recognized it when I put in the code: CustomNode.new()

Maybe this solution is obvious for some people, but not for me.

Thank you!

by (24 points)
0 votes

Could you provide the code of the CustomNode, please? Maybe it's something there.

Also, did you activate the plugin on the project settings? You can check it on Project > Project Settings > Plugins, and see if your plugin appears there and is activated.

by (56 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 Frequently asked questions and 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 [email protected] with your username.