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

Hello to all,

Is there a problem in connecting undefined signals?

For example:
get_node('my_node').connect( 'signal', self, 'function')
Now supose that the node my_node have no 'signal' defined.

I tested it and it is working fine for now (the game doesn't crash), but is there a chance it could cause some weird problems in the future? It just seems wrong


in Engine by (26 points)
edited by

1 Answer

+2 votes
Best answer

This just sets up listening for that signal. If the signal isn't defined on mynode it won't be emitted, but nothing bad will happen, you'll just never call function.

by (22,191 points)
selected by

Though nothing bad happening could be a bad thing, since it will be hard to catch the error unless you already suspect the signal handling to be broken.

Thanks for the answer! I asked because I will probably have to reuse the node and not all parents will emit the signal

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.