diff --git a/Source/Nakatomi/EnemyCharacter.cpp b/Source/Nakatomi/EnemyCharacter.cpp index ecdfadf..cbc97e9 100644 --- a/Source/Nakatomi/EnemyCharacter.cpp +++ b/Source/Nakatomi/EnemyCharacter.cpp @@ -112,6 +112,15 @@ void AEnemyCharacter::ProcessHits(TArray hits) if (Hit.GetActor()) { + if (auto interactableComponent = Hit.GetActor()->GetComponentByClass()) + { + interactableComponent->Interact(); + } + + if (auto healthComponent = Hit.GetActor()->GetComponentByClass()) + { + healthComponent->TakeDamage(Hit.GetActor(), CurrentWeapon->GetWeaponProperties()->WeaponDamage, nullptr, GetController(), this); + } } } } diff --git a/Source/Nakatomi/PlayerCharacter.cpp b/Source/Nakatomi/PlayerCharacter.cpp index 34cde4f..67fa85e 100644 --- a/Source/Nakatomi/PlayerCharacter.cpp +++ b/Source/Nakatomi/PlayerCharacter.cpp @@ -284,11 +284,9 @@ void APlayerCharacter::ProcessHits(TArray hits) interactableComponent->Interact(); } - if (Hit.GetActor()->ActorHasTag("Enemy")) + if (auto healthComponent = Hit.GetActor()->GetComponentByClass()) { - // TODO: Do thing - auto enemy = Cast(Hit.GetActor()); - enemy->GetHealthComponent()->TakeDamage(Hit.GetActor(), CurrentWeapon->GetWeaponProperties()->WeaponDamage, nullptr, GetController(), this); + healthComponent->TakeDamage(Hit.GetActor(), CurrentWeapon->GetWeaponProperties()->WeaponDamage, nullptr, GetController(), this); } } }