0 votes

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?

in Engine by (15 points)

1 Answer

+1 vote
Best answer

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

by (10,331 points)
selected by

Yep that seems to have fixed it. Thanks!

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!

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 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 webmaster@godotengine.org with your username.