Signal is emitted but Autoload node never receives it

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

When calling a custom signal that only has 1 argument. The method that receives the signal also only has 1 parameter. I am now getting this error: emit_signal: Error calling method from signal ‘died’: ‘Node(’: Method expected 1 arguments, but called with 2…

The signal is connected according to the print statements (connect and is_connected support this as well); but it can never be disconnected or can’t be found?

Edit: I found the error but encountered a nastier one. My error before was that I connected the signal passing a parameter and when I emitted it, I passed an additional one.

My new error is this:


This is my output in the console the first time the code runs:

Is Signal connected?
Attempting to connect
Connected successfully
Is signal STILL connected?

The second time:

Is Signal connected?
Attempting to connect

For some reason something disconnects it. Not only that but it still thinks it’s connected. Is this a huge engine bug?

Additional details:

  • The code posted is inside of a resource script. In the scene this resource lives as a variable inside of a 2D node.

  • When the signal is emitted it passes “self” as an object and not as a Resource.

The problem with using a picture instead of the code tag {} is that now I can’t just copy/paste.
You say the output includes "Connected successfully" but I don’t see that print statement anywhere in the code.
The if statement in the function connect_signals incorrectly reports "connected" when "died" isn’t connected (you are using not is_connected). That print statement should read print("Attempt to connect unsuccessful").
Prior to "Is Still Connected", does the emit_signal("died") work? If so, does the function change_enemies_killed() disconnect the signal?
For what reason are you passing self to the signal function? Is this code inside an object that is instantiated more than once? If so, you may be getting overlap from the code running on two separate instances.
(I am more than a little suspicious of tossing self up the node hierarchy)

LeslieS | 2023-02-09 06:29

:bust_in_silhouette: Reply From: Guliver_Jham

Is this with godot 4? Because there the syntax isn’t:

connect(signal_string, object, signal_string)

It is:

connect(signal_string, function).

As in, the actual function in the node you want to call, without quotation marks.