Game runs, everything works but this error persists (Error calling method)

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

I am finishing the “first game” part of the tutorial.

I am proud of myself as I even managed to code a toggle button for keeping the keyboard controls :stuck_out_tongue:

However, I can’t get rid of this error message when the player dies:

E 0:00:06.128 emit_signal: Error calling method from signal ‘hit’: ‘Area2D(’: Method not found…
<C++ Source> core/object.cpp:1260 @ emit_signal() @ _on_Player_body_entered()

As I said, the game works, the score resets and the HUD pops up and you can play again, but the debugger still has this error in it.

I tried disconnecting and reconnecting and have checked that part of the code in completed projects for this game. Everything seems to be the same as in my code.

I am a beginner, can you point me in the right direction?

Just saying it out, double check the spelling in the connect method call, make sure everything is 100% the same(even caps), if that doesnt help try rewriting the function and the function call…

The engine cannot find the method specified in a connect statement, so he throws an error.

if you connected it through the editor then try reconnecting or connecting via code

rustyStriker | 2020-07-11 17:58

:bust_in_silhouette: Reply From: shmellyorc

the line that says ‘ @ _onPlayerbodyentered()’. go to your script, scroll down to line 75 where function ‘_onPlayerbodyentered()’ should be located.

also, theirs no function called ‘gameover’, which you connected the area2d to: Area2D(

Lines 73 to 76 in the player code (

func _on_Player_body_entered(_body):
$CollisionShape2D.set_deferred(“disabled”, true)

Behind this function there is a connection arrow stating:
Player → body_entered Player

Lines 44 to 50 in

func game_over():
get_tree().call_group(“mobs”, “queue_free”)

Behind this function there is a connection arrow stating:
Player → hit Main

I found out what was wrong. Thanks for pointing me in the right direction as asked!

I had somehow added an extra connection in the Player scene apart from the one existing in the Player scene inside the Main scene. I have no idea how it got there. After carefully removing that one (and all the others out of spite) and reconnecting from the “Player” child of “Main” it worked. It had to be something like this as the game worked fine.


Samomba | 2020-07-12 17:12