How to work with a scene if it is a child node

Godot Version

Stable 4.2

Question

World (Scene)

  • UI (PackedScene)

UI (Scene) (There is a signal, which then triggers a signal in the HotBar)

  • HotBar (Node)

I have a “World” scene in which I put a “UI” scene, that is, in “World”, I cannot directly interact with the child nodes of “UI”. There is a node “HotBar” in the “UI” scene. I have a script in my autoloader “GlobalScript” that is connected to “World”. In it, I tried to emit (emit_signal) my custom signal in “UI” using @onready var ui = $UI, but it didn’t work (ui.emit_signal(…)). Then I tried loading the scene itself into GlobalScript via preload(…).instantiate() and also tried to emit the signal, but it also didn’t work (or rather it did, but I was accessing a packed scene that is not modified, and I need to work in real time). So, what is the best way to uncompress the signal so that it works in real time?
That is, I need a sequence of calls from GlobalScript “World” I send a signal to “UI”, and from “UI” the received signal, sends a signal to “Hotbar”

I think what you’re looking for is to enable the “Editable children” option in the scene instance:

1 Like

I did this, but I still don’t have anything working. When I access the UI it says it doesn’t exist - null

Anyway, I’ve solved the problem. I think it’s because of the autoloading of the script, when we load it, it is automatically detached from the scene and you can’t make for example the @onready variable anymore, because the script has the path /root/… So that’s how it is.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.