I'm working on a project in 2.1.4, which is mostly just GUI interfaces and switching between scenes at the moment. Scene tree looks like this:
- main (Node)
-- instanced scene 1 (Control)
-- instanced scene 2 (Control)
... and so on (instanced in the editor rather than code btw). Now if I want a button press in scene 1 to activate a function in scene 2, what is the best way to go?
I've tried signals, but I've spent three evenings trying various approaches to this (signal manager singleton, get_tree().get_root().get_node()
), but the latter always seems to return a null instance, and the former is even more complicated. Of course, I've tried to link by creating the signal and linking through the editor signal window too, but that doesn't produce anything!
Has anyone got any advice to achieve something like this? Any help would be much appreciated.
EDIT: The problem was that I was using get_tree().change_scene()
, which was reinstancing a scene on its own, when I wanted it to just switch between them. I've since swapped to hiding and showing the various scenes, and signals are now working using the ("../scene1")
etc., which I know is bad practice, but i'll come back and tidy up once i've finished a prototype.