Disconnect all incoming signals

Godot Version

v4.2.1.stable.official [b09f793f5]

Question

I’m trying to disconnect all incoming signals from the scene that other scenes are sending signals to. Apparently I’m supposed to get all the incoming signals, and then disconnect them like:
image
(from here, by good Thearot)

The “get_incoming_connection” indeed gets all the signals the scene is meant to receive, but the rest is just giving me errors ("Invalid get index ‘signal name’ ")… I have tried all kinds of other variations using the “disconnect” magical word but no matter what I try it’s not working. What am I missing?

The example you found was written for Godot 3.x, and the way it works was changed in 4.0. Check the documentation for more information.

ok now I can at least get the signals to print, that’s progress

for cur_conn in conns:
	print(cur_conn.signal)
	print(cur_conn.callable)

But how do I use the array that the get_incoming_connection is returning?

From the same Help page, I’m supposed to use disconnect and use the signal name and a callable as parameters… So I tried with variations of
disconnect(cur_conn.signal, cur_conn.callable)
but I’m only managing to get different error messages.

ok found it, it’s
disconnect(str(cur_conn.signal), cur_conn.callable)
Edit: argh no it’s not

This should work:

cur_conn.signal.disconnect(cur_conn.callable)

Thanks, I would have never guessed it on my own (as can be seen from my attempts :smiley: )

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.