I projected to the screen using a USceneCapture2D.
Get the ViewInfo first somewhere:
FMinimalViewInfo ViewInfo;
USceneCaptureComponent2D* CaptureComponent; //Initialize this first somewhere
CaptureComponent->GetCameraView(0.0f, ViewInfo);
then call this function to project it from WorldPos to ScreenPos:
bool Project2Screen(FMinimalViewInfo& CapturedView, const FVector& ViewLocation, const FRotator& ViewRotation, const FVector3d& WorldPos, FVector2d& ScreenPos, int32 ImageHeight, int32 ImageWidth)
{
ScreenPos = FVector2d(0.0, 0.0);
const FMatrix ProjectionMatrix = CapturedView.CalculateProjectionMatrix();
FMatrix ViewPlanesMatrix = FMatrix(
FPlane(0, 0, 1, 0),
FPlane(1, 0, 0, 0),
FPlane(0, 1, 0, 0),
FPlane(0, 0, 0, 1));
const FMatrix ViewRotationMatrix = FInverseRotationMatrix(ViewRotation) * ViewPlanesMatrix;
const FMatrix ViewMatrix = FTranslationMatrix(-ViewLocation) * ViewRotationMatrix * ProjectionMatrix;
FIntRect InRect(0, 0, ImageWidth, ImageHeight);
return FSceneView::ProjectWorldToScreen(WorldPos, InRect, ViewMatrix, ScreenPos);
return false;
}
Hope this helps!