C++ HUD Not Drawing

I am going through the video tutorials found here: A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums1-_Overview to learn how c++ can be incorporated with blueprints. I ran into a snag at the very end of the series, on drawing the HUD that shows the score. Below is some of my relevant code:
GameMode Initialization:

ABatteryGameGameMode::ABatteryGameGameMode()
{
	// set default pawn class to our Blueprinted character
	static ConstructorHelpers::FClassFinder<APawn> PlayerPawnBPClass(TEXT("/Game/ThirdPerson/Blueprints/ThirdPersonCharacter"));
	if (PlayerPawnBPClass.Class != NULL)
	{
		DefaultPawnClass = PlayerPawnBPClass.Class;
	}

	HUDClass = ABatteryGameHUD::StaticClass();

	DecayRate = 0.125f;
}

And my DrawHUD function:

void ABatteryGameHUD::DrawHUD()
{
	UE_LOG(LogTemp, Warning, TEXT("DrawHUD called"));
	FVector2D ScreenDimensions = FVector2D(Canvas->SizeX, Canvas->SizeY);

	Super::DrawHUD();

	ABatteryGameCharacter* MyCharacter = Cast<ABatteryGameCharacter>(UGameplayStatics::GetPlayerPawn(this, 0));
	FString PowerLevelString = FString::Printf(TEXT("%10.1"), FMath::Abs(MyCharacter->PowerLevel));

	DrawText(PowerLevelString, FColor::White, 50, 50, HUDFont);

	ABatteryGameGameMode* MyGameMode = Cast<ABatteryGameGameMode>(UGameplayStatics::GetGameMode(this));

	if (MyGameMode->GetCurrentState() == EBatteryGamePlayState::EGameOver)
	{
		FVector2D GameOverSize;
		GetTextSize(TEXT("GAME OVER"), GameOverSize.X, GameOverSize.Y, HUDFont);

		DrawText(TEXT("GAME OVER"), FColor::White, (ScreenDimensions.X - GameOverSize.X) / 2.0f, (ScreenDimensions.Y - GameOverSize.Y) / 2.0f, HUDFont);
	}
}

But when I play the game, the logging at the top of my DrawHUD function never shows up, so I know this function isn’t being called. Finally, here is a screen shot of my Default Modes section of the Project Settings. According to this, the correct class is specified as the HUD class for my project.

Let me know if any more information would be helpful to diagnosing the problem.

Hello, sigi0073

Sorry to hear about your problem. This behavior may occur in the situation when override specifier hasn’t been used in the place of DrawHUD() function declaration.
Thus, please make sure that you DrawHUD() function is declared like this:

virtual void DrawHUD() override;

Hope this helped!

Good luck!

In my header, DrawHUD() already has the override specifier. Here is the content of the header for my HUD class:
// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "GameFramework/HUD.h"
#include "BatteryGameHUD.generated.h"

/**
 * 
 */
UCLASS()
class BATTERYGAME_API ABatteryGameHUD : public AHUD
{
	GENERATED_BODY()

public:
	ABatteryGameHUD(const FObjectInitializer& ObjectInitializer);


	UPROPERTY()
		UFont* HUDFont;

	/*primary draw call for the HUD*/
	virtual void DrawHUD() override;	
	
};

So I tried out your code:

My Code:

my TestHud.h
// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "GameFramework/HUD.h"
#include "TestHud.generated.h"

/**
 * 
 */
UCLASS()
class ENVIRONMENTWINDOW_API ATestHud : public AHUD
{
	GENERATED_BODY()
	
public:
	ATestHud(const FObjectInitializer& ObjectInitializer);


	UPROPERTY()
		UFont* HUDFont;

	/*primary draw call for the HUD*/
	virtual void DrawHUD() override;
	
	
};

my TestHud.cpp
// Fill out your copyright notice in the Description page of Project Settings.

#include "EnvironmentWindow.h"
#include "TestHud.h"

ATestHud::ATestHud(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{

}


void ATestHud::DrawHUD()
{
	UE_LOG(LogTemp, Warning, TEXT("DrawHUD called"));
	FVector2D ScreenDimensions = FVector2D(Canvas->SizeX, Canvas->SizeY);

	Super::DrawHUD();

	//ABatteryGameCharacter* MyCharacter = Cast<ABatteryGameCharacter>(UGameplayStatics::GetPlayerPawn(this, 0));
	FString PowerLevelString = FString::Printf(TEXT("%10.1"), FMath::Abs(10));//MyCharacter->PowerLevel));

	DrawText(PowerLevelString, FColor::White, 50, 50, HUDFont);

	//ABatteryGameGameMode* MyGameMode = Cast<ABatteryGameGameMode>(UGameplayStatics::GetGameMode(this));

// 	if (MyGameMode->GetCurrentState() == EBatteryGamePlayState::EGameOver)
// 	{
// 		FVector2D GameOverSize;
// 		GetTextSize(TEXT("GAME OVER"), GameOverSize.X, GameOverSize.Y, HUDFont);
// 
// 		DrawText(TEXT("GAME OVER"), FColor::White, (ScreenDimensions.X - GameOverSize.X) / 2.0f, (ScreenDimensions.Y - GameOverSize.Y) / 2.0f, HUDFont);
// 	}
}

And this works for me (I commented out lines which referred to classes that I did not have). I get a log spammed with:

LogTemp:Warning: DrawHUD called
LogTemp:Warning: DrawHUD called
LogTemp:Warning: DrawHUD called
LogTemp:Warning: DrawHUD called

However, though since ATestHud::HudFont was never set, nothing is drawn.

Suggestion:

Check that you’ve not overridden the gamemode in world settings:

Huh, I hadn’t looked at this project in a while, but it turns out that I am getting exactly what you described. I am currently learning how to use the Unreal Engine, and started this project after experimenting with Blueprints. The Blueprint “Print” function prints to the screen as well as the log, and I had assumed the same would happen with UE_LOG(), which is why I wasn’t seeing that debug notice popping up. Thanks for letting me know about setting the font, once I did that it is now showing up as my HUD.

Actually, adding constructor solved my problem, greetings.