hitbox changes
This commit is contained in:
@@ -90,6 +90,12 @@ func _on_hitbox_hit(target: Node, damage_amount: float, knockback_amount: float,
|
||||
if not target or not owner_character:
|
||||
return
|
||||
|
||||
# Flash the target's hurtbox red for visual feedback
|
||||
if target is Node:
|
||||
var hurtbox = target.find_child("HurtBox", true, false)
|
||||
if hurtbox and hurtbox.has_method("flash_hit"):
|
||||
hurtbox.flash_hit()
|
||||
|
||||
hit_connected.emit(target)
|
||||
|
||||
# Route damage through server
|
||||
@@ -145,7 +151,7 @@ func perform_attack() -> bool:
|
||||
attack_performed.emit()
|
||||
return true
|
||||
|
||||
## Activate the hitbox for attack detection using frame data timing
|
||||
## Activate the hitbox for attack detection - active for entire animation
|
||||
func _activate_hitbox():
|
||||
if not _hitbox:
|
||||
return
|
||||
@@ -153,21 +159,14 @@ func _activate_hitbox():
|
||||
# Update owner reference in case it changed
|
||||
_hitbox.owner_entity = owner_character
|
||||
|
||||
# STARTUP PHASE - Wait before activating hitbox (wind-up)
|
||||
var startup = weapon_data.startup_time if weapon_data else 0.15
|
||||
if startup > 0:
|
||||
await get_tree().create_timer(startup).timeout
|
||||
|
||||
if not _hitbox or not is_instance_valid(_hitbox):
|
||||
return
|
||||
|
||||
# ACTIVE PHASE - Hitbox is on, can deal damage
|
||||
# Activate hitbox immediately for entire animation duration
|
||||
_hitbox.activate()
|
||||
|
||||
var active = weapon_data.active_time if weapon_data else 0.2
|
||||
await get_tree().create_timer(active).timeout
|
||||
# Keep active for the full attack cooldown
|
||||
var duration = weapon_data.attack_cooldown if weapon_data else 0.5
|
||||
await get_tree().create_timer(duration).timeout
|
||||
|
||||
# RECOVERY PHASE - Hitbox off (recovery time is remaining cooldown)
|
||||
# Deactivate when attack is complete
|
||||
if _hitbox and is_instance_valid(_hitbox):
|
||||
_hitbox.deactivate()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user