Invalid call. Nonexistent function 'take_damage' in base 'KinematicBody2D'.

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

Hi. I have an enemy node (KinematicBody2D) and a player. When the player’s sword detects enemy body entered it is going to call enemy’s take_damage func but it is throwing an error.
some snippets:

sword:

func _on_Sword_body_entered(body):
if body.is_in_group("enemy"):
	print(body.name)
	body.take_damage(damage)'

enemy:

func take_damage(count):
hp -= count

couldnt be simpler, yet, this doesnt work and im curious why

What the print shows?
You probably made a mistake somewhere. This could include adding a wrong scene to the group or no script attached to the enemy instance due to a script error.

Dlean Jeans | 2019-07-10 18:03

print show the body name correctly

szaross | 2019-07-10 18:22

:bust_in_silhouette: Reply From: BraindeadBZH

Do this tutorial is of any help? https://www.youtube.com/watch?v=JBczf8qt04c