#Inheritance in class-scripts not working with signals

3 messages · Page 1 of 1 (latest)

fathom imp
#

I have a script enemy.gd that I'm using as the base script for all of the enemies in my game. It has a method _on_death() that I'm connecting to the signal death in the component that handles HP, so that I can have enemies handle their own deaths.

However, when I extend from enemy.gd, and the signal goes off, I get an error:

E 0:00:04.288   emit_signal: Error calling method from signal 'death': 'KinematicBody2D(knight.gd)::_on_death()': Method not found..
  <C++ Source>  core/object.cpp:1242 @ emit_signal()
  <Stack Trace> StatsComponent.gd:56 @ ReceiveDamage()
                Hitbox.gd:37 @ _on_Hitbox_area_entered()

Does inheritance not include methods? Does it only skip methods that start with an underscore? Does it only break on signals? I've been using inheritance just fine elsewhere in this project, I'm not sure what's breaking this.

#

For clarity and to cover some things I've already checked:

  • The death signal has no parameters, and neither does _on_death().
  • I've already checked for typos.
#

I appear to have fixed it. My connect call looked like this:

stats.connect("death",self,"_on_death()");