I ran the code but my enemy didn't die.

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

extends “res://src/Actors/Actor.gd”

func _ready() → void:
set_physics_process(false)
_velocity.x = -speed.x

func _on_StompDectector_body_entered(_body: Node) → void:
if _body.global_position.y > get_node(“stompDetector”).global_position.y:
return
get_node(“CollisionShape2D”).disabled = true
queue_free()

func _physics_process(delta: float) → void:
_velocity.y += gravity * delta
if is_on_wall():
_velocity.x *= -1.0
_velocity.y = move_and_slide(_velocity, FLOOR_NORMAL).y

ERROR E 0:00:04.110 emit_signal: Error calling method from signal ‘body_entered’: ‘KinematicBody2D(Enemy.gd)::_on_stompDetector_body_entered’: Method not found…
<C++ Source> core/object.cpp:1242 @ emit_signal()

:bust_in_silhouette: Reply From: Gluon

The error message is saying it cannot find

onstompDetectorbodyentered

which is because the stomp isnt capitalized your method is called

onStompDectectorbodyentered

if you change your method to have a lower case S in stomp it should work

I tried it and it’s not the same and error says.

E 0:00:13.410 emit_signal: Error calling method from signal ‘body_entered’: ‘KinematicBody2D(Enemy.gd)::_on_stompDetector_body_entered’: Method not found…
<C++ Source> core/object.cpp:1242 @ emit_signal()

Anantasak08 | 2022-11-15 14:20

You also have a spelling error in the originally posted code.

This:

func onStompDectectorbodyentered(body: Node) -> void:

(notice the Dectect)

For future, to find this yourself…

If you perform a search (in the Godot editor) for the method name shown in the error and iterate through the matches, you’ll see that it won’t find your actual method (because of the typo) - indicating the problem…

jgodfrey | 2022-11-15 14:33