Export parent scenes children

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

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.

:bust_in_silhouette: Reply From: gioele

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