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)
VSZ
(VSZ)
2
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.
VSZ
(VSZ)
4
Great! Btw mark this question as answered (the check mark thingee) if your issue has been resolved!