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;
}
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.
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:
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;
};
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.