SchildDerStaerke/scripts/hurtbox.gd

16 lines
398 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
#print(owner.unit_name + " take damage by " + hitbox.owner.unit_name + "...")
if owner.has_method("take_damage"):
owner.take_damage(hitbox.get_damage())