0 votes

First of all I'm new to godot and trying to follow some tutorials to produce a very basic game, the current tutorial is teaching to make a game in which the player dodges enemies. However when a collision is detected nothing happens as the method cannot be found even though it all seems to be spelled correctly, giving the error:

emitsignal: Error calling method from signal 'bodyentered': 'Area2D(Player.cs)::PlayerHit': Method not found..

The connection is made in the ready procedure for the player.

Connect("body_entered", this, nameof(PlayerHit));

and this is the routine I'm trying to get it to call:

public void PlayerHit()
    Hide(); // Player disappears after being hit.
    GetNode<CollisionShape2D>("CollisionShape2D").SetDeferred("disabled", true);

Any help would be greatly appreciated.

in Engine by (15 points)

1 Answer

+1 vote
Best answer

body_entered expects the function to receive a Node, you need to change the function to this:

public void PlayerHit(Node body) { ... }
by (1,002 points)
selected by

Thanks so much i was really stuck and it was as simple as that :)

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.