SchildDerStaerke/scripts/hurtbox.gd

10 lines
300 B
GDScript

class_name HurtBox extends Area3D
func _ready() -> void:
connect("area_entered", _on_area_entered)
func _on_area_entered(hitbox: HitBox) -> void:
if hitbox == null or hitbox.owner == owner: return
if owner.has_method("take_damage"):
owner.call("take_damage", hitbox.get_damage())
queue_free()