0 votes

Hi!

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

Thanks!

  • Mike
in Engine by (85 points)

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

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

Please log in or register to answer this question.

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.