Download

Basic Canvas Hud Issue

Hi, just wanna try to get a basic canvas hud working but nothing seams to show and there are no compile errors, here are my files:

.h



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

/**
 * 
 */
UCLASS()
class SNIPERTEST_API ASniperHUD : public AHUD
{
	GENERATED_BODY()

	ASniperHUD();

	UPROPERTY()
	UFont* HUDFont;

	virtual void DrawHUD() override;
};


.cpp



#include "SniperTest.h"
#include "SniperHUD.h"
#include "SniperPawn.h"

ASniperHUD::ASniperHUD()
{
	static ConstructorHelpers::FObjectFinder<UFont>HUDFontOb(TEXT("/Game/SniperContent/SniperFont.SniperFont"));

	HUDFont = HUDFontOb.Object;
}

void ASniperHUD::DrawHUD()
{
	Super::DrawHUD();

	DrawText(TEXT("Hi"), FColor::White, 500, 500, HUDFont);
}


I created a bp for my gamemode so I could set the value of the hud to myhud, but I have no clue if the hud class is actually being called at all. Anyone got any ideas?

Before anyone pitches the Widget thing, I been working with basic canvas for years and prefer the freedom to do what I need without running into “Widget” limitations.

I haven’t worked with the Canvas for like a year, so i don’t see any problems in your code.

But i can tell you how to check if the code is being called:

Add


GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Red, FString("TEST"));

into the constructor of the HUD and when you start the game, it should show up (:

Nope still got nothing, i guess My hud code isnt running at all, not even if I that code on a keybind function



	APlayerController* C = Cast<APlayerController>(Controller);

	if (C->MyHUD != NULL)
		ShowScope();


K ran this on a keybound function, showscope works on a different keybind so i know that works, it also works is i just call it on the scope but when I dig around trying to find a hud, apparently there isnt any. I started the project with a blank slate c++
maybe I have to spawn the hud class my self?

Lol after restarting the engine it works, guess the settings ini or something needed to be updated…