Error calling method from signal: Method not found

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

So, I’ve got the following code inside my script:

	for i in multiples_ids:
	var multi = instance_from_id(i)
	multi.connect("not_touched", self, "multi_is_untouched(multi)")

func multi_is_untouched(multi):
if multi.get_node("Area2D").overlaps_area($Hole3/Area2D):
	move_multi_to_respos(multi)

However, when the multi object emits the signal “not_touched”, nothing happens.
I can see this error in the debugger:

emit_signal: Error calling method from signal ‘not_touched’: ‘Node(Main.gd)::multi_is_untouched(multi)’: Method not found…
<C++ Source> core/object.cpp:1242 @ emit_signal()
Multiple.gd:29 @ _unhandled_input()

Since I have 3 multis instantiated, I find it important for the move_multi_to_respos() function to have a reference to the multi emitting the signal. (I could make a workaround in case the signal can’t pass the argument through the function, though)

Any advice?

:bust_in_silhouette: Reply From: SQBX

Change this line

multi.connect("not_touched", self, "multi_is_untouched(multi)")

To

multi.connect("not_touched", self, "multi_is_untouched")

Where in your script multi emits the not_touched signal, use:

emit_signal("not_touched", self)

And when the not_touched signal is defined, replace it with

signal not_touched(multi)

When you connect the signal to the function, it will automatically pass the required parameters.

Worked perfectly. Thank you very much!

gonzalezharry | 2023-01-02 23:28

Happy to help :slight_smile:

SQBX | 2023-01-02 23:30