Can we connect a Signal without knowing the emitter Node?

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

Can I connect a signal without knowing the node, but only using the signal’s name? Something like:

signal  Update_The_Popcorn

func OnTouchToast():


func Signal_Digest(SIGNAL):
        "Update_The_Popcorn": $Popcorn.Implode()
:bust_in_silhouette: Reply From: null_digital

AFAIK, you must call connect() on the object with the signal you’d like to connect to. In your example, you’re trying to connect a method of NodeB to a signal of NodeB. You’d have to do something like:

var node_a =
node_a.connect(“Update_The_Popcorn”, self, “Signal_Digest”, [SIGNAL])

:bust_in_silhouette: Reply From: selamba

As far as I know, no. There are however two ways to circumvent this problem that I can think of.

  1. Add an intermediary node that will listen for the signals. For example, if you don’t know who emits signal A, just use the _ready function of signal A emitters to connect to the intermediary listener, and then the listener will relay signal B to signal B listeners upon receiving signal A.

  2. Find a way to make a node just listen for a signal directly, so that no matter who emits signal A, all signal A listeners will react.

Having a intermediary node was something I thought about doing with autoloads or using groups, it works, thanks for the suggestions, cheers.

The_Black_Chess_King | 2019-12-08 18:57

:bust_in_silhouette: Reply From: Robster

A signal manager to handle all the signals in the game. Super easy. Hope that helps