First_Person_Slapper/Scripts/HurtBox.gd
Victor Turgeon d31b299251 monke
2022-10-11 21:21:27 -04:00

21 lines
574 B
GDScript

class_name HurtBox
extends Area
func _init():
collision_layer = 0
collision_mask = 2
func _ready():
connect("area_entered",self,"_on_area_entered")
func _on_area_entered(hitbox: HitBox):
if hitbox == null:
return
if hitbox.hitbox_type == hitbox.HitboxType.Unassigned:
return
if hitbox.hitbox_type == hitbox.HitboxType.Slap and owner.has_method("get_slapped"):
owner.get_slapped(hitbox.slap_level,hitbox.slap_kill, hitbox.slap_vector)
elif hitbox.hitbox_type == hitbox.HitboxType.Projectile and owner.has_method("get_shot"):
owner.get_shot(hitbox.owner)