OnHit - How to check for a specific actor?

OnHit(AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)

So I’m very much a beginner in Unreal Engine 4 (only started a few days ago). How can I do something like this?

if (OtherActor->GetClass == AEnemy)

You have a couple of options:

Use

if(OtherActor->IsA(AEnemy::StaticClass())

if you want to filter AEnemy actors and also actors subclassed from AEnemy

or use

if(OtherActor->StaticClass() == AEnemy::StaticClass())

if you want just AEnemy actors

or you can even use

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

for actors subclassed by AEnemy alone

HTH

Thank you very much for a great response. Multiple options are always nice to have.

Great! Btw mark this question as answered (the check mark thingee) if your issue has been resolved!