Fix error checking

This commit is contained in:
baz 2025-07-17 21:45:08 +01:00
parent a35b1f0893
commit a2d483dcc2

View File

@ -42,14 +42,12 @@ void ASwarmAgent::OnSwarmAgentBeginOverlap(UPrimitiveComponent* OverlappedCompon
if (!EnemyHealthComponent->GetIsDead()) if (!EnemyHealthComponent->GetIsDead())
{ {
AController* ownerController = nullptr;
if (AVampireCharacter* character = Cast<AVampireCharacter>(GetOwner())) if (AVampireCharacter* character = Cast<AVampireCharacter>(GetOwner()))
{ {
ownerController = character->GetController(); AController* ownerController = character->GetController();
AWeapon* ownerWeapon = Cast<AWeapon>(GetOwner());
EnemyHealthComponent->TakeDamage(Enemy, ownerWeapon->Damage, nullptr, ownerController, this);
} }
AWeapon* ownerWeapon = Cast<AWeapon>(GetOwner());
EnemyHealthComponent->TakeDamage(Enemy, ownerWeapon->Damage, nullptr, ownerController, this);
} }
} }
} }