The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

What happens or what is the side effect (if any) to connect the same signal to the same node and callable, multiple times?

For example:

var nodes = get_tree().get_nodes_in_group("group-name")
    for n in nodes:

Will the callable be "re-assigned" to the node if already connected? Does it work the same way as assigning the same value to the same variable multiple times?

Or, will the node have multiple references to the same Callable?

Thank you all!

Godot version 4
in Engine by (16 points)

1 Answer

0 votes

This is the sort of thing you can test in a sandbox project in 2 minutes.

Godot 3.x threw an error if you tried to connect to an already existing function, I don't see why it would be any different in 4.0.

by (1,957 points)

Correction to my own comment below... @zhyrin is right. The engine will throw an error when trying to connect the same signal more than once. It will not crash the game, but will output the error to the ERRORS tab, as in:

E 0:00:01:0036 @ _connectControlsFxSignal(): Signal 'mouse_entered' is already connected to given callable 'Control(' in that object.

Right.. I made a simple test.

Added a new button, a couple functions and connected them like so:

func _ready():

func A():

func B():

I've got no errors. And the output was:


So, it seems like Godot4 just ignore if the same function is connected more than once for the same signal.

That's great to hear.
Personally I don't think it should be an error, only a warning.

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 Frequently asked questions and 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 [email protected] with your username.