SchildDerStaerke/scripts/hurtbox.gd

16 lines
353 B
GDScript

class_name HurtBox
extends Area3D
func _init() -> void:
collision_layer = 0
collision_mask = 2
func _ready() -> void:
connect("area_entered", _on_area_entered)
func _on_area_entered(hitbox: HitBox) -> void:
if hitbox == null: return
if hitbox.owner == owner: return
if owner.has_method("take_damage"):
owner.take_damage(hitbox.get_damage())