Hithurtboxes
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
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
|
||||
Reference in New Issue
Block a user