How can i check if an hit actor is from a certain class

Basically i want to add a particle system to my projectile when i hit something that is not from the ACharacter class.

my code looks like this

if (OtherActor->GetClass()->IsChildOf(AFPSCharacter::StaticClass()))

but thats not working.

Can anyone point me to a solution for checking if HitActor != ACharacter


Have you tried these two solutions:

if(!OtherActor->IsA< AFPSCharacter >())
    // The other Actor is not of type AFPSCharacter


if(!Cast< AFPSCharacter >(OtherActor)
    // Other Actor is not AFPSCharacter.

I have used the first one in my code before:

TArray<FHitResult> HitResults;
	GetWorld()->LineTraceMultiByChannel(HitResults, TraceStart, TraceEnd, ECC_GameTraceChannel14, TraceWeaponParams);

	for (auto& HitResult : HitResults)
		if (HitResult.Actor->IsA<AHeroCharacter>())
			UGameplayStatics::ApplyDamage(HitResult.Actor.Get(), MeleeDamage, this->GetController(), this, MeleeDamageType);

Hope this helps.

Hey, thank you!

the second solution worked for me