Getting Actor From Line Trace

Hi, i’m trying out the line tracing in unreal 4 but i’m having some problems with the returned pointer from the hit result.

    FHitResult testHitResult(ForceInit);
	UWorld* TheWorld = this->GetWorld();
	FVector testStartFVector = this->GetActorLocation();
	FVector testEndFVector = testStartFVector + GetActorForwardVector() * RayLength;
	FColor debugColor = FColor::Red;

	FCollisionQueryParams TraceParams(TEXT("MyTrace"), true, this);
	TraceParams.bTraceComplex = true;
	TraceParams.bTraceAsyncScene = true;
	TraceParams.bReturnPhysicalMaterial = false;
	if (TheWorld->LineTraceSingle(testHitResult, testStartFVector, testEndFVector, ECC_WorldStatic, TraceParams))
   	   if (testHitResult.GetActor())
			GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Blue, TEXT("Found"));
			if (testHitResult.GetActor()->GetName() == "BoxBrush")
				debugColor = FColor::Blue;
				debugColor = FColor::Red;
		DrawDebugLine(TheWorld, testStartFVector, testHitResult.Location, debugColor, false, 30.0f, 1.0f, 3.0f);

In the current level i have a couple of placed boxes using the Box Brush and from what i understand they should be inherited from AActor which should give them access to the get name function that i’m calling as well as the GetActor from the test hit result.

Am i doing something wrong or anyone have another suggestion about how i can do this?

Hi! I suspect the hit result you are getting back has no actor, but will have a component. Geometry Brushes should populate the hit with Hit.Component being a valid UModelComponent*. Unfortunately however I don’t think it’s possible to get an AActor from the model component, as the model is responsible for rendering the geometry as a whole, not individual brushes.

Right, so i’ll create another class that i can use for checking if i hit it.
Thanks for the answer!