Setting a HUD within the GameMode class

I am not quite sure what I am doing wrong here. I have successfully set my DefaultPawnClass previously, but for some reason the HUD just won’t want to work. For some reason I can’t change it within Project Settings either.

My code as of now is

static ConstructorHelpers::FClassFinder<AHUD> HUDObject(TEXT("HUD'/Game/Blueprints/MyHUD_BP.MyHUD_BP'"));
if (HUDObject.Class != NULL)
{
	HUDClass = (UClass*)HUDObject.Class;
}

I have figured out that the ClassFinder cannot find the blueprint, however I have it, I copied the path with Copy Reference just to be extra sure, plus the DefaulPawnClass has been initialised similarly …

What am I missing ? Thanks in advance.

Hello, I believe it’s done this way.

AFPSGameMode::AFPSGameMode()
{
	// set default pawn class to our Blueprinted character
	static ConstructorHelpers::FClassFinder<APawn> PlayerPawnClassFinder(TEXT("/Game/Blueprints/BP_Player"));
	DefaultPawnClass = PlayerPawnClassFinder.Class;

	// use the custom HUD class
	HUDClass = AFPSHUD::StaticClass();
}

Thank you, it worked. I might just ditch the use of a HUD blueprint altogether.

Hello, I’ve tried this fix but every which way I’ve tried, my desired HUD Blueprint fails to invoke when I run my GameMode. Am I doing something unusual here? Imgur: The magic of the Internet

no idea if it’s still relevant, but as I came here searching for a solution to this problem, I assume others may get here too. I don’t yet have a solution, but what solved the problem for the OP was that he revoked the use a blueprint HUD object altogether and simply avoided the problem. This is not a solution because that means the OP doesn’t have a HUD blueprint class in use.

What the person I’m replying to did was to find the class and put the finder value in a variable, but then doing nothing with it and just setting the HUD class to the default most fundamental HUD class (which is AHUD).

I should update that I found a solution which works at least for me - add:

|#include “GameFramework/HUD.h”

to the ConstructorHelpers.h file.