UWidgetComponent HUD does not keep consistent screen size when zooming / changing distance – how to fix?

Hi everyone,

I’m working on an RTS-style project in UE5 where each regiment actor has a floating HUD using a UWidgetComponent.

Here is how I set it up:

HUDWidget = CreateDefaultSubobject<UWidgetComponent>(TEXT("HUDWidget"));
HUDWidget->SetupAttachment(RootComponent);
HUDWidget->SetWidgetSpace(EWidgetSpace::Screen); // or World depending on tests
HUDWidget->SetRelativeLocation(FVector(0.f, 0.f, 250.f));
HUDWidget->SetDrawSize(FVector2D(200.f, 60.f));
HUDWidget->SetDrawAtDesiredSize(true);

The widget is a UUserWidget (URegimentHUD) containing progress bars and a text label.


Problem

I want the HUD to:

  • always appear the same size on screen

  • regardless of:

    • camera distance

    • zoom level

    • camera rotation

Right now, the widget’s perceived size changes depending on how far the camera is or how much I zoom in/out.


Question

What is the correct way to make a UWidgetComponent behave like a true screen-space HUD element, while still being attached to a world actor?

I want it to stay anchored above the unit but maintain a constant screen size like UI/HUD elements.


What I already tried

  • SetWidgetSpace(EWidgetSpace::Screen)

  • SetDrawAtDesiredSize(true)

  • adjusting SetDrawSize(...)

But I still can’t get consistent screen-size behavior.


Context

This is for an RTS system with many units, each showing health and morale bars above their formation.