How do you access an embeded node?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By John97

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.

:bust_in_silhouette: Reply From: Bubu

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

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.

John97 | 2021-04-15 01:20

Write the path of the node as a string.

Bubu | 2021-04-15 01:23

Parse Error: The method “get_node” isn’t declared on base “String”.

John97 | 2021-04-15 01:25

Example:

var size = self.get_node("Sprite")

Bubu | 2021-04-15 01:26

That worked. Thanks.

John97 | 2021-04-15 01:41

Happy to help.

Bubu | 2021-04-15 01:42

:bust_in_silhouette: Reply From: exuin

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