Help with : Error calling method method could not be found

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

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:

emit_signal: Error calling method from signal ‘body_entered’: ‘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.

:bust_in_silhouette: Reply From: davidoc

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

public void PlayerHit(Node body) { ... }

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

Polyaxial | 2020-05-23 12:12