![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | VarionDrakon |
Good day, friends, need your advice on how to get a node from another scene using C#?
![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | VarionDrakon |
Good day, friends, need your advice on how to get a node from another scene using C#?
![]() |
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:
GetTree().Root.GetNode("NodeGodot").GetNode<Node2D>("ChildNodeGodot");
or
GetTree().Root.GetNode("../NodeGodot").GetNode<Node2D>("../ChildNodeGodot");
or
GetTree().Root.GetNode("NodeGodot").GetNode<Node2D>("../ChildNodeGodot");
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