How do I connect to a signal without using the node that has the signal?

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

When wanting to connect to signals you need to have a reference to the script that emits that signal. So I want to know, is there a way to connect to a signal without the reference so that you’d just have to type the name of the signal in the connect() function?

:bust_in_silhouette: Reply From: cm

It’s pretty common to do this with an event bus autoload. The idea is that you define the signal in an autoload, and then connect and emit form there: (added as an autoload named EventBus)

signal my_signal()

func _ready() -> void:
    EventBus.connect("my_signal", self, "on_my_signal")

func on_my_signal() -> void:
    print("my signal was called")

func emit_signal() -> void:

This way and don’t have to know anything about eachother… they only have to know about the

1 Like