FCollisionShape HitSphere = FCollisionShape::MakeSphere(TacticalRange);
GetWorld()->SweepMultiByChannel(
OutHits,
PlayerCharacter->GetActorLocation(),
PlayerCharacter->GetActorLocation(),
FQuat::Identity,
ECC_GameTraceChannel1,
HitSphere);
for (int32 i = 0; i < OutHits.Num(); i++)
{
if (OutHits[i].GetActor()->IsA(AEnemy::StaticClass()))
{
FEnemyData EnemyHit = { Cast<AEnemy>(OutHits[i].GetActor()) };
EnemiesHitByTactical.Add(EnemyHit);
}
}
UE_LOG(LogTemp, Warning, TEXT("number of enemies hit %i"),
EnemiesHitByTactical.Num());
UE_LOG(LogTemp, Warning, TEXT("number of actors hit %i"),
OutHits.Num());
You can just remove the check against the bool you are assigning to the return value of SweepMultiByChannel, there’s no need to use it if you only care about overlaps