# TSet to get only actors once after a sweep multi?

**URL:** <https://forums.unrealengine.com/t/tset-to-get-only-actors-once-after-a-sweep-multi/471289>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [September 13, 2020, 1:04pm UTC](https://forums.unrealengine.com/t/tset-to-get-only-actors-once-after-a-sweep-multi/471289 "2020-09-13T13:04:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![11Mdp](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@11Mdp](https://forums.unrealengine.com/u/11Mdp)\
**Post date:** [September 13, 2020, 1:04pm UTC](https://forums.unrealengine.com/t/tset-to-get-only-actors-once-after-a-sweep-multi/471289/1 "2020-09-13T13:04:37Z")

</div>

Hello, I’m still a newbie so I don’t know if there’s a better method to do this.  
SweepMultiByChannel fills the TArray with all the components it intercepts, but I’m using it to generate a grenade explosion, so I want to damage each actor inside its range only once.  
In order to achieve this I wrote the following code:

```
TArray<FHitResult> ComponentsInExplosionRange;

GetWorld()->SweepMultiByChannel(
    ComponentsInExplosionRange,
    HitComponent->GetComponentLocation(),
    HitComponent->GetComponentLocation(),
    FQuat::Identity, ECC_Pawn,
    FCollisionShape::MakeSphere(300.f)
);

TSet<APawnBase*> HitPawns;
for (const auto& Component : ComponentsInExplosionRange)
{
    const auto ActorHit = Cast<APawnBase>(Component.GetActor());
    if (ActorHit)
    {
        HitPawns.Add(ActorHit, nullptr);
    }
}

for (const auto& Pawn : HitPawns)
{
    UGameplayStatics::ApplyDamage(
        Pawn,
        Damage,
        ProjectileOwner->GetInstigatorController(),
        this,
        DamageType
    );
}

```

This is working, but is it a good approach to the problem? Or are there more efficient/elegant ways to obtain the same results?  
Thank you!
