Since the blueprint is 100% C++, how do I now add HUD-components like progressbars to it? I can’t even get the right header it seems even though this should be the one according to: UProgressBar | Unreal Engine Documentation
The solution must be insanely simple.
// Set the crosshair texture
static ConstructorHelpers::FObjectFinder<UTexture2D> CrosshiarTexObj(TEXT("/Game/FirstPerson/Textures/FirstPersonCrosshair"));
CrosshairTex = CrosshiarTexObj.Object;
UProgressBar EnemyHPBar; // <<<< identifier UProgressBar is undefined
UMG is essentially a wrapper for Slate that allows us to build out widgets in the editor with blueprints. If your intention is to work solely in C++, you’ll want to create a Slate progress bar instead of a UMG progress bar. Alternatively, you can create your HUD widget in UMG through the editor and write your own HUD class to attach it to the viewport.
You’ll want to include “SlateBasics.h”, hopefully that will clear up your errors. Additionally, I would suggest creating your own custom slate widget to add the progress bar to, and adding that custom widget to your HUD.
Thanks, adding “SlateBasics.h” fixed all compiler errors.
The tutorial you linked was up2date but had 2 minor mistakes that prevented it from compiling (probably a typo):
Should be (at 2 places):
After that you should get the “Hello, Slate!” in red text at the top of the viewport as intended. Also note that you have to close VS and RMB on your .uproject and click “Generate Visual Studio Files”. Otherwise VS may not recognize the changes.
But I still have no real idea of how to add a simple SProgressbar using slatewidgets. Everything I try so far raises errors.
Also I welcome a more detailed tutorial (preferably video) explaining slatewidgets into detail. I find loads of UMG/Blueprint tutorials but not a single usable one for slatewidgets in C++.
Perhaps I’ll go with your alternative solution you mentioned earlier. It seems much much more simpler and accomplishes the same:
Alternatively, you can create your HUD widget in UMG through the editor and write your own HUD class to attach it to the viewport.