+3 votes

I'm still learning Godot, so please forgive me, if my questions sound stupid. It's not on purpose, it's just me in this case. ;-)

As far as I read about it, it seems to me that the signaling system is implemented only half way when it comes to decoupling nodes.

While it is fantastic that every node can emit signals (build-in and custom) at any time, it is a bit odd to me, that the receiving node has to know exactly(!) which node emits a certain signal in order to receive it. (If I understood the mechanism correctly.)
That is not, what I would call "loose coupling".

In my opinion the receiving node should only register itself for a certain signal at a central object in the system, let' call it SignalHUB, and receive information no matter who emitted the signal. That would really decouple it from the emitter and would probably work across the whole application.

I'm sure one could implement such a central SignalHUB quite easily with GDScript and place it near the root of the project. But I'm wondering some things:

  1. Does Godot maybe already have such a central signal distributor that could be used for such an approach?
  2. Would you recommend the use of this pattern as it creates a possible bottle neck at the central SignalHUB node?
  3. Would you encourage the use of signals in general to control ALL (inter)actions in a middle to large application? (Or should the use of signals be limited to a number of usecases?)

Edit: corrected typo

in Engine by (21 points)

1 Answer

0 votes

This is super much up to how you prefer to work. I myself try to use signals between scenes that are connected at the time of instancing into an active scene. It seems to be a smoother experience to connect signals via code compared to the GUI.

It is worth mentioning that groups are very nice to work with if you are doing something more "instance-specific" (?) that would need a "SignalHUB "

by (911 points)

Thanks for your feedback.

I think it's not that much if you design your application to work with signals from scratch.

But shortly after I posted my question I read about node groups and the possibility to trigger methods on all nodes that belong to a given group.
This does indeed seem to work better to decouple event emitter and event consumer in Godot.

Of course node groups are probably limited to synchronous events whereas signals are (or could also be?) processed asynchronously. This could make a difference in performance if there are many events/signals.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.