I got the same results as Ben.
// Get World Location if linetrace through crosshair, true if hits land
bool AStarshipPlayerController::GetSightRayHitLocation(FVector& HitLocation) const // GetSightRayHitLocation
{
// Find the crosshair position
int32 ViewportSizeX, ViewportSizeY;
GetViewportSize(ViewportSizeX, ViewportSizeY);
auto ScreenLocation = FVector2D
(
OUT CrossHairXLocation * ViewportSizeX,
OUT CrossHairYLocation * ViewportSizeY
);
FVector HitDirection; // OUT Parameter
FVector WorldCameraLocation; // Throw away
// "de-project" the screen position of the crosshair to the world direction
auto WorldDirection = DeprojectScreenPositionToWorld(ScreenLocation.X, ScreenLocation.Y, WorldCameraLocation, HitDirection);
UE_LOG(LogTemp, Warning, TEXT("World Direction: %s"), *HitDirection.ToString());
// Line-trace along that look direction, and see what we hit (up to maximum range)
return false;
}
Just curious.
Warm Regards,
K-B