0 votes

Hi,

I'm new to godot, working on my first project and I've come to a bit of a head scratcher. Pardon if my terms are not exactly on point.

I'm trying to find out if there is a way to export a variable that lists all of the child scenes of a scene that the current scene is in.

It's a mouthful, but to make it easier - I have a scene (LocationNode) that I place in another scene (MainWindow). I want to reuse the LocationNode so I wouldn't have to create a new scene for every location since they serve the same purpose.

The export is needed so I could select another LocationNode that the current one is connected with. Sort of like making a binary tree:

Binary tree exmple

Sorry if my explanation is a bit confusing, my closest experience with an engine like godot comes from GameMaker and it has a seperation between objects/rooms, where as here everything seems to be a scene.

in Engine by (12 points)

1 Answer

0 votes

Every new file that you create is a scene.
A scene has a scene tree listing a hierarchy of its components, the nodes.
To simply get all children of a scene/node you could use get_children()

You can use Godot default nodes or reuse other scenes you already created as nodes (a node is a scene within another scene).

A branch of the scene tree can be saved as a new scene, it will become a reusable separate file. Right click on a node and choose Save branch as scene.

Maybe this can help.

Or maybe you need to create a generic Location with its own custom script, then add another instance of it in scene and make a customized scene (a child) by right click and Extend script

by (290 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 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.