Hi all,
I'm pretty new to Godot and I'm a bit lost with this error.
I use gdScript.
I have created a class "Enemy" which holds basic variables, like "life", "speed", etc., which is a KinematicBody2D.
Then I have a "Slime", which extends Enemy and is attached to a KinematicBody2D Scene. A child scene is an Area2D, called "Hurtbox".
Now I want to implement the signal "area_entered" of the Hurtbox to signal to a method in Slime. This method is not declared in Enemy.
In Slime I have connected the signal in _ready:
# Slime.gd
extends Enemy
var hurtbox
func _ready():
hurtbox = $Hurtbox
hurtbox.connect("area_entered", self, "_on_Hurtbox_area_entered")
func _on_Hurtbox_area_entered(bullet : Area2D):
print("in _on_Hurtbox_area_entered")
emit_signal("hit")
[...]
Well, the function works. I have removed a bit more of the logic, but the "hit" signal is emitted and the enemy looses life and dies correct.
But every time the function is called, I get the following error in the Debugger:
E 0:00:07.292 emit_signal: Error calling method from signal 'area_entered': 'Area2D::_on_Hurtbox_area_entered': Method not found..
<C++ Source> core/object.cpp:1242 @ emit_signal()
I tried connecting the signal in the editor, but it has the same effect.
I also tried declaring the function in the parent class Enemy. But that also changes nothing.
Thanks for your help.