0 votes

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

Godot version 3.2.3 Stable
in Engine by (149 points)

1 Answer

+1 vote

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);

by (224 points)

Not working. Example:







Return console:

ERROR: Node not found: NodeGodot.

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

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 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 webmaster@godotengine.org with your username.