0 votes

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 :p

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

E 0:00:06.128 emitsignal: Error calling method from signal 'hit': 'Area2D(Player.gd)::gameover': Method not found..
<C++ Source> core/object.cpp:1260 @ emitsignal()
Player.gd:75 @ _on
Playerbodyentered()

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?
Regards.

in Engine by (30 points)

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

1 Answer

+1 vote
Best answer

the line that says 'Player.gd:75 @ onPlayerbodyentered()'. go to your player.gd 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(Player.gd)::gameover.

by (107 points)
selected by

Lines 73 to 76 in the player code (Player.gd)

func onPlayerbodyentered(body):
hide()
emit
signal("hit")
$CollisionShape2D.set_deferred("disabled", true)

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

Lines 44 to 50 in Main.gd

func gameover():
$ScoreTimer.stop()
$MobTimer.stop()
$HUD.show
gameover()
get
tree().callgroup("mobs", "queuefree")
$Music.stop()
$DeathSound.play()

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.

Thanks!

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 Frequently asked questions and 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 [email protected] with your username.