PlayerCameraManager->GetCameraLocation VS DeprojectScreenPositionToWorld WorldLocation

I would like to understand why we should use one or the other way to get the starting point of the array.

During the chalenger I used DeprojectScreenPositionToWorld Location and WordDiretion, and seems to be working fine.

There seems to be no major diference with either solution

DeprojectScreenPositionToWorld(ScreenLocation.X, ScreenLocation.Y, CameraWorldLocation, WorldDirection);
	//CameraWorldLocation = PlayerCameraManager->GetCameraLocation();
		FHitResult OutHit;
		FVector FinalLineLocation = CameraWorldLocation + WorldDirection*LineTraceRange;

I see now reason not to.

The optimal way is to use the Location returned by DeprojectScreenPositionToWorld(), since this gets calculated anyway. Hence, recalculating it using GetCameraLocation() is not necessary.

How is it that we can use either camera location from camera manager or the location returned by DeprojectScreenPositionToWorld? I mean the latter returns the projection location of the crosshair onto the world, correct and that is not same as the camera? The input to our deprojection is our cross hair screen position which is not same as the camera which is behind the tank when starting the game.

1 Like

I’m a bit confused as well on the purpose discarding the World Location from DeprojectScreenPositionToWorld as it seems like that’s exactly what we want for the starting position for the line trace.

From testing though it looks like either method creates the same line trace through the crosshair. So getting camera location I think is an extra unnecessary step

As far as i can tell there is little difference between using The World Location or the Camera Location

The direction will cast the point throw the world position of the hud pixel in anyway, the main difference is the starting point.
In the picture i draw a red line from the Camera Location and the green line from the World Location

So the difference would result in you aiming a little bit further in the case where you use the world location, and the danger of hitting culled object in the case where you use the camera location.

Privacy & Terms