I’ve got FHitResult* and FCollisionQueryParams*, for my line trace function, in the header file and initialized like this;
FHitResult* RV_Hit = new FHitResult(ForceInit);
FCollisionQueryParams* RV_TraceParams = new FCollisionQueryParams(ForceInit);
just before the function is called in the cpp file. The function returns a true on hit, and then on the next line I try and use the getactor() function in the hit result to find out what class it is;
if (RV_Hit->GetActor()->GetClass()->IsChildOf(AInteractor::StaticClass())) {}
This line is crashing the editor. I can’t see anything wrong with it except maybe the FHitResult isnt working?
And also make sure to check actor is valid before dereferencing it!
AActor* FoundActor = RV_Hit->GetActor();
if(!FoundActor)
{
//UE_LOG that actor was not found for some reason
return;
}
//Is found actor an interactor?
if (FoundActor->IsA(AInteractor::StaticClass())) {}