0 votes

When you make an instance of a node in another scene, it contains a copy of all of the sub-nodes that were in its template, like a sprite. How do you access a node's copy of that sub-node, it's own sprite? It's there, but it has no visible path.

in Engine by (44 points)

2 Answers

+1 vote

I'm don't know a better way but I just reference the instance and call get_node().

by (298 points)
var size = self.get_node(Sprite)

Parse Error: At "get_node()" call, argument 1. The passed argument's type (GDScriptNativeClass) doesn't match the function's expected argument type (NodePath).

When I use the name of the node instead of self
The identifier "name" isn't declared in the current scope.

Write the path of the node as a string.

Parse Error: The method "get_node" isn't declared on base "String".


var size = self.get_node("Sprite")

That worked. Thanks.

Happy to help.

0 votes

Additionally, you can right-click the instanced node in the node hiearchy and select "Editable children" to display the child nodes in the editor.

by (8,550 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.