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;
}
else
{
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?