Checking if an AActor is a parent of another Class

Hello,
So I am very new to both C++ and Unreal Engine, although I have experience in other languages, the UE library is completely foreign to me, so maybe someone can help me out here.
I have create a class called “UsableObject.h” which is a extension of AActor class, what I want to do is check if they player is looking at a AActor, using a SingleLineTrace. This works, I have traced objects, such as the demo chair and table objects. The next thing I want to do is see if my new Traced Actor is a UsableObject, if it is, then do etc.

What I have tried to do:

if (GetWorld()->LineTraceSingle(HitData, Start, End, ECC_Pawn, TraceParams)){
		if (HitData.GetActor())
		{
			if (HitData.GetActor()->IsA(AUsableItem::StaticClass()){
				GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("Trace"));
			}
		}
	}

This doesn’t work, Any suggestions?

Also, my object does not have any collision, so I do not know how to add that/if I need to.

Thanks,
Joel Comberiati

Try replacing:

if (HitData.GetActor()->IsA(AUsableItem::StaticClass())

with:

if (HitData.GetActor() == AUsableItem::StaticClass())

or:

if (HitData.GetActor()->IsChildOf(AUsableItem::StaticClass())

Also, just switched to SingleLineTraceByChannel, but same results

actually there is an error unless you use:

  if(HitData.GetActor().GetClass() == AUsableItem::StaticClass())

Thank you for the help

This is strange, with perception this way of comparing fails.

It seems like its comparing a AActor to a UClass, which is invalid, the rest of my code is not working, so I cannot test this out for sure.