The following method:
https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/AHUD/DrawText/1/index.html
Seems to be incorrect with respect to how the text is positioned and with how it is setup. First I don’t quite get why “const float Y = Canvas->ClipY/3.0f - YL/2.0f + Position.Y;” is dividing by 3? I assume this is trying to move the origin to the center of the screen, so I am guessing that 3.0f should be a 2.0f. Also the passed in color is not used since the FCanvasTextItem created is also not used and the text is drawn using “Canvas->DrawText(TextFont, Text, X, Y, FontScale.X, FontScale.Y);” instead of “Canvas->DrawItem( TextItem );”.
I am guessing the function should look like this:
void AHUD::DrawText(const FString& Text, FVector2D Position, UFont* TextFont, FVector2D FontScale, FColor TextColor)
{
float XL, YL;
Canvas->TextSize(TextFont, Text, XL, YL);
const float X = Canvas->ClipX/2.0f - XL/2.0f + Position.X;
const float Y = Canvas->ClipY/2.0f - YL/2.0f + Position.Y;
FCanvasTextItem TextItem( FVector2D( X, Y ), FText::FromString( Text ), TextFont ? TextFont : GEngine->GetMediumFont(), FLinearColor( TextColor ) );
TextItem.Scale = FontScale;
Canvas->DrawItem( TextItem );
}
Thanks