Get node using only C#

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

Good day, friends, need your advice on how to get a node from another scene using C#?

:bust_in_silhouette: Reply From: Yaann

GetTree().Root.GetNode("Name of the Main Scene").GetNode<Node>("Node of the scene you want to use");
If you want to get the child node of a scene it’s basically the same thing but just with this addition:
GetTree().Root.GetNode("Name of the Main Scene").GetNode("Node of the scene you want to use").GetNode<Node>("Child Node of the scene);

Not working. Example:







Return console:

ERROR: Node not found: NodeGodot.

VarionDrakon | 2021-05-18 21:13

Have you made sure that you loaded your main scene node? Meaning the scene that shows up when you press play?

Yaann | 2021-05-19 09:30