Download

Why have a HUD class?

Hello,

I have created a main menu system in the past by using the UMG UI Designer,

I am now trying to code a HUD in UE4,

My question is, do I make a HUD class, or a Canvas class, or Widget Class?

The tutorials on-line do not go in depth, especially the UE4 one. I have searched the heavens and no good sources.

If I am to program my own user interface, how do I start, I am confused because of the Canvas, UMG, Slate, Widget etc.

HUD is not UI class, it is for storing player parameters… or preparing them for UI, i think.
I still not get the idea of HUD class myself. But the UI HUD i personally do using UMG, I think it is most preferred way now.

I Believe that the hud class server as an intermediate between pawn/controller to the actual Widget. It stores the variables, states and take care of all of that logic. At least that how i see it

I am using UMG for both HUD’s and Menu’s. They have been easy to work with. So, make a widget class. There’s a node, create widget where you can select your new widget class, then the node add to viewport. You can have more than one of them open at a time. So, while one of them can always be up, with health ammo etc. you can pop up others for say ingame pause menu, and remove it without interfering with your HUD widget.

UMG wasn’t always there. Before you had the UMG Widget, we mainly used Slate and in BPs only the HUD Classes “Draw HUD” function.
You can use that function to draw text and images on the screen by entering the exact pixel offset on the Screen etc.

Since UMG is available in BPs, the HUD class is mainly used to store the Widget and manage them, although widget don’t have to be in that
HUD Class. I, for example, don’t use the HUD class at all.

Another useful property of HUD is that in multiplayer games HUD objects only exist on clients. Local HUD objects may also exist on server if it is not dedicated. So HUD class can be used to store state and run behavior that only makes sense on client. This is usually UI-related stuff but it can be used for anything.

Legacy code, which gives you access to canvas drawing. It doesn’t really serve any purpose beyond that.

I use HUD class for displaying debugging info in an organized and easy manner: a dark background panel (by DrawRect()) and a lot of variables with a short description (by DrawText()), I need it to check several variables of the actual state of my custom pathfinder and AI system.

I asked me the same question, i finally found this article, i share it here :

HUD is still useful to set in your GameMode for throwing some simple debug text on screen. But yeah, C++ HUDWidget bypasses it completely now. Basically:

Game >> HUDWidget >> tell HUDBlueprint to do something

HUDBlueprint >> HUDWidget >> blueprint C++ callbacks

Also, if you really dislike UMG you could write your own custom C++ UI using the base HUD class.