How do you make enemy take damage?

Godot Version

v4.1.3

Question

i am having trouble making enemy take damage. here the code: if body.is_in_group(“enemy”):
get_node(body).take_damage(5)
print(“hi”)
it also doesn’t detect it can anyone help?

I apologize for my confusion, but where is the function that contains this code?
You might need to show more of your code for more people to be able to help.
Is it on a body_entered signal of some sort? (Just guessing from the (body) part of the code)

If it is in a body_entered signal of some sort, perhaps you could check your layers and masks, and make sure that they can interact with each other.

Those are my two main ideas, having not seen much of the code.

the func is func _on_body_entered(body): the code is a body_entered signal.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.