DeprojectScreenPositionToWorld vs GetCameraLocation for start location

So in the class version, we use DeprojectScreenPositionToWorld and discard the CameraWorlLocation. We then call
GetWorld()->LineTraceSingleByChannel(
HitResult,
StartLocation,
EndLocation,
ECollisionChannel::ECC_Visibility)
)
Here, we use PlayerCameraManager->GetCameraLocation for start location.

From my understanding, DeprojectScreenPositionToWorld creates a location vector and a direction unit vector based on a location from the 2D screen (i.e. a crosshair). GetCameraLocation gives a location vector for the camera. I logged the location of both

image

So my question is, would the value from DeprojectScreenPositionToWorld be more appropriate since it takes the aiming point into consideration where as the other just takes a general location of the camera. The difference seems small, but is definitely a factor, especially at long ranges.

The way I visualize the deproject location is the point marked by the aimingpoint just on the other side of the camera lense, whereas the camera position would be the center of the camera.

This is one of the things I criticised Ben for. It doesn’t make sense to make this 3 functions especially when no other function uses this and one of them is just to call a single function.

So yes, using the location already given to us with DeprojectScreenPositionToWorld makes a lot more sense to me.

Thank you. I’m also assuming it is more accurate given the intent. The way it is currently done gives the proper direction, but then uses a different vector location (albeit close) to start from.

Well it wouldn’t matter here as being 1 off isn’t going to be noticable at all.

My main issue with it is that it’s just essentially getting the same value in two different ways when it could just use the value it already has.

1 Like

Thanks again

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms