I am trying to cast a line trace from camera position to where it points to, but the trace is always going into the same direction. The code for the trace as well as screenshot of the debug line can be found below. I have replicated the code in blueprints and it works perfectly, which can be found below as well. What am I doing wrong that I don’t see?
constexpr int32 TraceLength = 5000;
const auto BeginTraceLocation = PlayerCameraManager->GetCameraLocation();
const auto EndTraceLocation = BeginTraceLocation + PlayerCameraManager->GetActorForwardVector() * TraceLength;
// temp
DrawDebugLine(GetWorld(), BeginTraceLocation, EndTraceLocation, FColor{ 255,0,0 }, true, 100, 0, 3);
FHitResult Hit{};
if(!GetWorld()->LineTraceSingleByChannel(Hit, BeginTraceLocation, EndTraceLocation, ECollisionChannel::ECC_Visibility))
{
return;
}
///.... handling result
As you can see, the trace line is always going into this single direction (C++ code)
Whereas this blueprint implementation works perfectly