How to reference an item in a scene (two scenes deep!)

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


I have a project that has 3 scenes:

Scene 1 ONLY has a cube in it.
Scene 2 has Scene 1’s cube in it (twice) (so there are two Scene 1 cubes.)
Scene 3 has a camera, and loads Scene 2 programatically.

I’m writing a script in Scene 3.

How do I reference one of the cubes in Scene 1? (Can you give me a code snippet that might help?)


  • Mike

Hi mike,

I dont know if there is another way, but there is the possibility to make childobjekts editable.

right-click on the note you want accsses too and click on editable child objects
after that you can bind an Function to your main node

gruen | 2019-05-02 08:19

You should always be able to address child nodes as long as they’re linked in the scene tree.
If you are unsure with the address, you can make the scene tree visible by makeing the childobjects visible/editable in the editor (when the scene is already linked at that time).

When you link/add a scene as child of another then you can address that child node directly (that is the root node). If you change the name of the linked scenes root node in the parent (by editor or by script) then use that changed name as well in the node address.
It’s like `$“Scene2Root/Scene1Root.visible=false”. (You just have to put all parent/childs “on the way” in the path. So if Scene 1 actually has a i.e. Spatial as root node and the cube/MeshInstance is child of that spatial then the spatials name must also be put in the path.

For specific details, we need info about the node trees of the three scenes (and where the child scenes are linked).

wombatstampede | 2019-05-02 16:04