Sphere trace hitting the same actor multiple Times

const bool Hit = UKismetSystemLibrary::SphereTraceMultiForObjects(GetWorld(),StartSphere,EndSphere,Radius,
objectTypesArray,false,
ActorsToIgnore,EDrawDebugTrace::Persistent,HitArray,true,FLinearColor::Gray,
FLinearColor::Blue,5.f);

	if(Hit)
	{
		TSet<AActor*> AlreadyDamageActors;
		for(const FHitResult HitResult : HitArray)
		{
			AActor* HitActor = HitResult.GetActor();
			AlreadyDamageActors.Add(HitActor);
			for(AActor* Actor : AlreadyDamageActors)
			{
				GEngine->AddOnScreenDebugMessage(-1,5.f,FColor::Orange,FString::Printf(TEXT("Hit %s"),*Actor->GetName()));
			}
          }

iam calling the code on AnimNotifyState Using the receivedTickFunction what iam trying to do with this line of code is hit multiple targets but only once each any help will be appreciated thanks for your time :smiley:

1 Like

it hits each collision component so you could use AddUnique to get the actors once

i’ve tried that it didnt work thats why iam using Tset apprently is a more optimised array for the exact thing iam trying to do