How do I solve "error calling method from signal" error

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

I have an Area2D node and in the script I try to connect it’s parent node (also an Area2D) to a signal.

extends Area2D

onready var swipeDetector = get_tree().get_root().get_node("mainScene").get_node("swipeDetector")

func _ready():
    get_parent().connect("mouse_exited", get_parent(), "onMouseOutOfRange")
func onMouseOutOfRange():
	swipeDetector.outOfRange = true

But when I try to run it I get this error:

E 0:00:02.592   emit_signal: Error calling method from signal 'mouse_exited': 'Area2D::onMouseOutOfRange': Method not found..
  <C++ Source>  core/object.cpp:1228 @ emit_signal()

Anyone know what I can do to fix this?

:bust_in_silhouette: Reply From: njamster

If you get this error, then the parent node simply does not have a function called onMouseOutOfRange!

Yep that seems to have fixed it. Thanks!

RZaga09 | 2020-08-30 11:32

You can see in the code I attached that I do infact have a function called onMouseOutOfRange.

Yes, I saw that. However, that does not mean that the parent of this node has such a function as well! Unless they share the same script. That would only delay the problem though, because then the parent node would try to connect the mouse_exited signal to an onMouseOutOfRange-function in its own parent node - and that would fail!

njamster | 2020-08-30 11:39