Hello,
I have this code which sends a line trace from my player’s weapon to the place that they are looking. Then I use the OutHit.GetActor() to do some stuff. This works fine for the static meshes and characters in the level but when I added a geometry brush actor and fired at that OutHit.GetActor() returns NULL. I know the line trace hits the stairs because LineTraceSingleByChannel returns true.
if (GetWorld() != NULL)
{
APlayerCharacter* playerOwner = Cast<APlayerCharacter>(this->GetOwner());
if (playerOwner != NULL)
{
FHitResult OutHit;
FVector Start = playerOwner->GetFirstPersonCameraComponent()->GetComponentLocation();
FVector ForwardVector = playerOwner->GetFirstPersonCameraComponent()->GetForwardVector();
FVector End = ((ForwardVector * LineTraceLenght) + Start);
FCollisionQueryParams CollisionParams;
CollisionParams.AddIgnoredActor(this->GetOwner());
if (GetWorld()->LineTraceSingleByChannel(OutHit, Start, End, ECC_GameTraceChannel1, CollisionParams))
{
UE_LOG(LogTemp, Warning, TEXT("Hit Somthing"));
if (OutHit.GetActor() == NULL)
{
UE_LOG(LogTemp, Warning, TEXT("Couldnt get the actor"));
}
}
}
}
Is there a problem with the line trace or am I supposed too convert the brushes into a static mesh? I would rather not, because apart from the line trace stuff it already does what I need for testing.