Emiting Signals and Recieving

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

I’m doing a little project and i came across a new kind of problem, how to emit a signal from a script within a scene that is instanced in another scene.

what i need to do is this:

Scene1 —> Script —> Emit Signal
Instanced in
MainScript —> Recieve Signal —> Unstance (Scene1) —> Instance (Scene2)

:bust_in_silhouette: Reply From: Asthmar

I’m not sure if I fully got your question right but you want to signal between a main scene and an instanced scene? Here is a simple way

  1. You can add a script to your main scene root and a script to you instance scene while it’s in the main scene and from there you can emit signals
    Adding scripts

  2. Add Editable children
    add children

  3. Connect signals

1 Adding scripts Imgur: The magic of the Internet
2 add children Imgur: The magic of the Internet
3 signals Imgur: The magic of the Internet

:bust_in_silhouette: Reply From: Razorback1911

I’m not sure about your problem but there is maybe a solution with GdScript.

Scene1 Script :
-signal mySignal

On MainScript where you try to receive the signal, add :

-Scene1Instance.connect("mySignal", self, "functionToConnect")

If the Scene1 is not instancied by code you can use the $ to select the node instancied.
The signal may need to be connected before the emit_signal.