Where do you assign game's HUD class?

Looking through the ShooterGame, while I see it’s HUD, I can’t tell where it’s type is assigned to be used?

The documentation doesn’t seem to have anything on it.

The HUD class is set by assigning a value to the HUDClass variable in the GameInfo - generally in the constructor. For ShooterGame, it is set in the AShooterGameInfo constructor:

HUDClass = AShooterHUD::StaticClass();

It was hiding in the Online filter. Thanks, I feel like a newb.

I have a question following this if I may. When creating a new game project from a template I can never choose which classes to use (HUD, character, …) in the project preferences / quick settings. It’s grayed out.


If I choose a template without code though it is overridable. Could you please tell me how to make it changeable from the editor when it’s not ?

Thans in advance.

You can chang it you AGameMode class same solution above suggest in C++, you can do that in defults of gamemode bluepint

I found out that I could do it after creating a new game mode there. But not if I select the one that was created in the source code.

Ahhh dot you see it in original anwser? :slight_smile: and this to constructor of GameMode

HUDClass = AShooterHUD::StaticClass();

Replace AShooterHUD with your class

That’s not what I asked. That’s just to specify the HUD class to use. That doesn’t make it changeable from the Editor. I wanted to be able to specify a blueprint to be used for example.

Then create blueprint gamemode with you c++ gamemode as parent which will only override the HUD setting :slight_smile:

Yeah I already said above (3 messages) that it worked after creating a new game mode from the editor. But I just wanted to know if it could be possible to have a single C++ game mode using a blueprint HUD set within the editor.

Sorry for late responce, there is way to get blueprint call in C++ but it more clanky then one i proposed ealier. Put that in constructor of you child of AGameMode:

static ConstructorHelpers::FObjectFinder SomeBlueprint(TEXT("Blueprint'/Path/To/Blueprint'"));
HUDClass = (UClass*)SomeBlueprint.Object->GeneratedClass

You can get path to you blueprint by right click it in content browser and selecting “Copy Reference”

Ok thanks that is gonna be my answer for using blueprint classes from c++ classes. As for the reason why it’s grayed out in the editor if anybody knows it could still be good to know.

For those still wondering how to do this (if any) if you create a blueprint HUD parenting the ShooterHUD, go to your ShooterGameMode.cpp and replace the ShooterHUD = ShooterHUD::StaticClass(); with:

static ConstructorHelpers::FClassFinder <AHUD> YourBlueprintName(TEXT("Your Blueprint Path"));
HUDClass = (UClass*)YourBlurprintName.Class;

This will keep the Canvas UI design and allow you to add blueprint based UI designs ontop of the Canvas C++ design.