Combo System
The combo system allows the player to chain sword attacks using animation events.
Only the player can perform combos. All enemies inherit the
IDamageable interface and take damage during valid windows.
GIF Preview
Main Responsibilities
- Listens for animation events to enable hit checks.
- Detects
IDamageableenemies in range. - Applies damage only to valid living targets.
Core Method (Trigger Check)
void PerformAttack()
{
Collider[] hitColliders = Physics.OverlapSphere(attackPoint.position, attackRadius);
foreach (Collider hit in hitColliders)
{
IDamageable damageable = hit.GetComponent<IDamageable>();
if (damageable != null)
{
damageable.TakeDamage(weaponDamage);
}
}
}
checks for valid targets during attack window
Controller Logic
public void StartAttack()
{
if (canAttack && !isAttacking)
{
animator.SetTrigger("Attack");
isAttacking = true;
}
}
triggers attack animation from controller