Why does bullet cause damage many times?

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

There is a bullet that must cause damage to enemy only when he enters in hurtbox of bullet(bullet must not destroy when collide). But it causes damage many times(like all time of existing)

if body_entered:
    for body in get_overlapping_bodies():
	    if body.has_method("_take_damage"):

Help pls

:bust_in_silhouette: Reply From: godot_dev_

You could add a flag on the bullet, whenever it collides and does damage, toggle the flag. Then only apply your presented damage logic if the flag isn’t enabled. This should achieve one-time damage bullets