Download

How can check if actor have specific Collision Channel?

I did this:


if (OutHit.Actor->IsA(FCollisionObjectQueryParams(ECollisionChannel::ECC_PhysicsBody)))
{
UE_LOG(LogTemp, Warning, TEXT("This is it!"));
}

But I have this error:
error C2240: ‘initalizing’ : cannot convert from ‘OtherClassType’ to ‘const UClass *’

IsA only tests is a class “is a” type of a class. That’s why it’s complaining. So Pawn is a type of Actor, Character is a type of Pawn, etc. You can’t just check for arbitrary properties with it.

Collision Channels are kept on the primitive component. The hit result should actually pass in the Primitive component that was hit.



if (OutHit.Component->GetCollisionObjectType() == ECollisionChannel::ECC_PhysicsBody)
{
    // Blah.
}


Thank you.