You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
879 B
28 lines
879 B
|
2 weeks ago
|
extends Area3D
|
||
|
|
class_name HurtBox
|
||
|
|
|
||
|
|
## A component that receives damage from HitBoxes
|
||
|
|
## Attach to any entity that can be damaged (players, enemies, destructibles)
|
||
|
|
## NOTE: This is a passive detection zone - HitBox handles the collision detection
|
||
|
|
|
||
|
|
## The entity that owns this hurtbox (should be a BaseUnit or similar)
|
||
|
|
@export var owner_entity: Node = null
|
||
|
|
|
||
|
|
func _ready():
|
||
|
|
# Auto-find owner if not set (traverse up to find BaseUnit)
|
||
|
|
if owner_entity == null:
|
||
|
|
var parent = get_parent()
|
||
|
|
while parent:
|
||
|
|
if parent is BaseUnit:
|
||
|
|
owner_entity = parent
|
||
|
|
break
|
||
|
|
parent = parent.get_parent()
|
||
|
|
|
||
|
|
# Configure collision - hurtboxes are on layer 5, detect nothing (passive)
|
||
|
|
collision_layer = 16 # Layer 5 (hurtbox)
|
||
|
|
collision_mask = 0 # Don't detect anything - hitboxes detect us
|
||
|
|
|
||
|
|
# Ensure we can be detected but don't detect others
|
||
|
|
monitorable = true
|
||
|
|
monitoring = false
|