4.4 HUD Code No Longer Works


Downloaded UE 4.4 yesterday started creating my project from scratch, copied all my code over, however the HUD drawing code provided in the Third Person C++ Tutorial no longer compiles.

This HUD code has worked as is in 4.2 through 4.3.1 and is from the video tutorial.

class TEST1_API ATest1InfoHUD : public AHUD

This code was using the Canvas property from parent class AHUD to obtain the screen size however this code now gives the following compiler error

1>D:\Development\Unreal Projects\Tutorial\4.4\Test1\Source\Test1\Private\Test1InfoHUD.cpp(34): error C2027: use of undefined type 'UCanvas'
1>          D:\Unreal Engine\Unreal Engine\Unreal Engine\4.4\Engine\Source\Runtime\Engine\Classes\GameFramework/Actor.h(1938) : see declaration of 'UCanvas'
1>D:\Development\Unreal Projects\Tutorial\4.4\Test1\Source\Test1\Private\Test1InfoHUD.cpp(34): error C2227: left of '->SizeX' must point to class/struct/union/generic type

And in VS2013 it unders lines Canvas with a red squigly


If I remove the code referring to the Canvas property, I now get another error for obtaining the Font in the constructor

static ConstructorHelpers::FObjectFinder<UFont>HUDFontObj(TEXT("/Engine/EngineFonts/SmallFont"));

The compiler error is

1>D:\Unreal Engine\Unreal Engine\Unreal Engine\4.4\Engine\Source\Runtime\CoreUObject\Public\UObject\ConstructorHelpers.h(92): error C2664: 'void ConstructorHelpers::ValidateObject(UObject *,const FString &,const TCHAR *)' : cannot convert argument 1 from 'UFont *' to 'UObject *'
1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>          D:\Unreal Engine\Unreal Engine\Unreal Engine\4.4\Engine\Source\Runtime\CoreUObject\Public\UObject\ConstructorHelpers.h(85) : while compiling class template member function 'ConstructorHelpers::FObjectFinder<UFont>::FObjectFinder(const TCHAR *)'
1>          D:\Development\Unreal Projects\Tutorial\4.4\Test1\Source\Test1\Private\Test1InfoHUD.cpp(18) : see reference to function template instantiation 'ConstructorHelpers::FObjectFinder<UFont>::FObjectFinder(const TCHAR *)' being compiled
1>          D:\Development\Unreal Projects\Tutorial\4.4\Test1\Source\Test1\Private\Test1InfoHUD.cpp(18) : see reference to class template instantiation 'ConstructorHelpers::FObjectFinder<UFont>' being compiled

Again, this code worked fine before 4.4 release.

Any help gratefully received

Hi SolarVelocity,

When you mention to the “Third Person C++ Tutorial,” is this the tutorial you are referring to?

No, I was referring to the Introduction to UE4 Programming video tutorial in the UE4 Tutorial You Tube channel

Oh, I just realized your link is a page of links to the videos … so yes that tutorial

Introduction to UE4 Programming - 17 - Coding a Canvas HUD

That works … thanks very much for you help in this matter :o)

Hi SolarVelocity,

I went through the tutorial this afternoon, and it looks like there were a few header file changes in 4.4 that threw off the Canvas code in the tutorial. In your TutorialCodeHUD.cpp file, add the following includes:

#include "Engine/Canvas.h"
#include "Engine/Font.h"

When you have added those lines, you should be able to build the project successfully. Please let us know if you run into any additional issues.