# Setting a HUD within the GameMode class

**URL:** <https://forums.unrealengine.com/t/setting-a-hud-within-the-gamemode-class/436604>\
**Category:** UI\
**Tags:** hud, reference-blueprint, unreal-engine, UE4, CPP, question\
**Created:** [October 28, 2018, 11:26pm UTC](https://forums.unrealengine.com/t/setting-a-hud-within-the-gamemode-class/436604 "2018-10-28T23:26:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![flying\_ghetti](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@flying\_ghetti](https://forums.unrealengine.com/u/flying_ghetti)\
**Post date:** [October 28, 2018, 11:26pm UTC](https://forums.unrealengine.com/t/setting-a-hud-within-the-gamemode-class/436604/1 "2018-10-28T23:26:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_1b1f8823](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_1b1f8823](https://forums.unrealengine.com/u/anonymous_user_1b1f8823)\
**Post date:** [October 29, 2018, 12:20am UTC](https://forums.unrealengine.com/t/setting-a-hud-within-the-gamemode-class/436604/2 "2018-10-29T00:20:56Z")

</div>

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();
}

```

---

<div class="post-metadata">

**Author:** ![flying\_ghetti](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@flying\_ghetti](https://forums.unrealengine.com/u/flying_ghetti)\
**Post date:** [October 29, 2018, 1:15am UTC](https://forums.unrealengine.com/t/setting-a-hud-within-the-gamemode-class/436604/3 "2018-10-29T01:15:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e528cee9](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e528cee9](https://forums.unrealengine.com/u/anonymous_user_e528cee9)\
**Post date:** [May 1, 2019, 10:55pm UTC](https://forums.unrealengine.com/t/setting-a-hud-within-the-gamemode-class/436604/4 "2019-05-01T22:55:31Z")

</div>

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](https://imgur.com/9xycVsD)

---

<div class="post-metadata">

**Author:** ![Dark6gg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dark6gg](https://forums.unrealengine.com/u/Dark6gg)\
**Post date:** [August 10, 2024, 2:15pm UTC](https://forums.unrealengine.com/t/setting-a-hud-within-the-gamemode-class/436604/5 "2024-08-10T14:15:19Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![Dark6gg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dark6gg](https://forums.unrealengine.com/u/Dark6gg)\
**Post date:** [August 10, 2024, 3:42pm UTC](https://forums.unrealengine.com/t/setting-a-hud-within-the-gamemode-class/436604/6 "2024-08-10T15:42:42Z")

</div>

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

|#include “GameFramework/HUD.h”

to the ConstructorHelpers.h file.
