The display position of the text in DrawDebugString is affected by the scale of the display.

Should refer to the Project() of DebugCanvas (not Canvas).


 -  Suggest Code

void AHUD::DrawDebugTextList()
    // ...
    // don't draw text behind the camera
    if ( ((WorldTextLoc - CameraLoc) | CameraRot.Vector()) > 0.f )

        // Project with DebugCanvas
//      FVector ScreenLoc = Canvas->Project(WorldTextLoc);
        FVector ScreenLoc = DebugCanvas->Project(WorldTextLoc);

        TextItem.SetColor( DebugTextList[Idx].TextColor );
        TextItem.Text = FText::FromString( DebugTextList[Idx].DebugText );
        TextItem.Scale = FVector2D( DebugTextList[Idx].FontScale, DebugTextList[Idx].FontScale);
        DebugCanvas->DrawItem( TextItem, FVector2D( FMath::CeilToFloat(ScreenLoc.X), FMath::CeilToFloat(ScreenLoc.Y) ) );
    // ...


Steps to Reproduce
  1. On windows pc, right click and select "Display settings".
  2. Change display scale value of 100% to 125%.
  3. Open attached project and launch PIE.


  The debug text is displayed in a location away from the Actor. 


  The debug text is displayed in the Actor's location. 


Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-99709 in the post.

Login to Vote

Affects Versions4.25
Target Fix5.0-m3
Fix Commit14329579
Release Commit14329579
CreatedSep 16, 2020
ResolvedSep 16, 2020
UpdatedApr 28, 2021
View Jira Issue