How IsChildOf() works with an array of classes?

Hi, so i got this function->

// Apply Damage To Multiple Actors by using HitResult Array
void UHelperFunctionLibrary::ApplyAOEDamage(TArray<FHitResult> HitArray, bool DidHitAnything, AActor* DamageCauser,
	TArray<TSubclassOf<UObject>> FilterClasses ,float Damage)
{
	//Local Hit Actors Array Variable
	TArray<AActor*> HitActors;

	if (DidHitAnything)
	{
			for (auto& HitElement : HitArray)
			{
				if (HitElement.Actor->GetClass()->IsChildOf<ACharacter>())
				{
					if (!HitActors.Contains(HitElement.Actor))
					{
						HitActors.Add(HitElement.GetActor());
						UGameplayStatics::ApplyDamage(HitElement.GetActor(), Damage, nullptr, DamageCauser, nullptr);
					}
				}
			}
	}
}

How can i loop through my FilterClasses array to check the actors that i need from a specific class?
Because its just not working this way →

for (auto& FilterClassElement : FilterClasses)
    {
        if (HitElement.Actor->GetClass()->IsChildOf<FilterClassElement >())
    	{
            // Stuff here
        }
    }

Hello Triplexx,

Can you please provide me with your full class (.cpp) and header (.h) files for this class?

Thank you!

This is the only function in this class.
In the first code that i linked, on the 12th line, I want to replace this part:

(It is working)
if (HitElement.Actor->GetClass()->IsChildOf())

with the code i linked second:

(It is not working)
for (auto& FilterClassElement : FilterClasses)
{
if (HitElement.Actor->GetClass()->IsChildOf())
{
// Stuff here
}
}

But it gives me error about the "FilterClassElement " passed in IsChildOf()

Hey, simply :
if FilterClassElement is a class object, then :

 for (auto& FilterClassElement : FilterClasses)
     {
         if (HitElement.Actor->GetClass()->IsChildOf(Cast<UClass>(FilterClassElement)) 
         {
             // Stuff here
         }
     }

if FilterClassElement is an object of the class, then :

 for (auto& FilterClassElement : FilterClasses)
     {
         if (HitElement.Actor->GetClass()->IsChildOf(FilterClassElement->GetClass())
         {
             // Stuff here
         }
     }

Thank you, It`s working pretty well! :smiley: