Pretty basic question:
I am using the side-scroller c++ template and wanted to add a blueprint created HUD.
I created a basic blueprint of parent type HUD. I then added the following code to my GameMode.cpp to call the blueprint. I based it off the pre-existing code that sets the default pawn class to the MyCharacter blueprint
Error 4 error MSB3073: The command ""G:\Program Files\Unreal Engine\4.4\Engine\Build\BatchFiles\Build.bat" ***** Win64 DebugGame "G:\Users\*****\Documents\Unreal Projects\*****\*****.uproject" -rocket" exited with code -1. G:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets 38 5 *****
Error 2 error C3861: 'StaticClass': identifier not found G:\Program Files\Unreal Engine\4.4\Engine\Source\Runtime\CoreUObject\Public\UObject\ConstructorHelpers.h 142 1 *****
Error 1 error C2027: use of undefined type 'AHUD' G:\Program Files\Unreal Engine\4.4\Engine\Source\Runtime\CoreUObject\Public\UObject\ConstructorHelpers.h 142 1 *****
Error 3 error : Failed to produce item: G:\Users\*****\Documents\Unreal Projects\*****\Binaries\Win64\UE4Editor-*****-Win64-DebugGame.pdb G:\Users\*****\Documents\Unreal Projects\*****\Intermediate\ProjectFiles\ERROR *****
(***** = censored)
Commenting out the code causes the errors to disappear. I searched around and can’t seem to find a solution. The Blueprint works perfectly fine in the side-scroller blueprint template as all i need to do is set it as the default.
Not quite sure what’s causing this to fail when using c++. Any ideas?
Found the answer and just as I guessed, it was something very basic.
I needed to simply add the following to my GameMode.cpp
However since I wanted to include a C++ class with my blueprint I simply created the class which included GameFramework/HUD.h and then called that in my GameMode.cpp.
Been a while since I used C++ and forgot that #includes can be nested, which is why the default for the side-scroller c++ template has “#include “GameFramework/Character.h”” in the Character.h but not in the GameMode.cpp. This gave me the false assumption that there was some inherent behavior that covered the include for default character, but turned out I just wasn’t smart enough!