Hi guys so im trying to make a hud appear, once a character overlap a triggerbox so heres my code, the name of my userwidget is “HelpTextHUD” i probobly forgot something but not sure what it is. so here is my code:
// .h file
// Reference UMG Asset in the Editor
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Widgets")
TSubclassOf<class UUserWidget> HelpTextHUD;
// Variable to hold the widget After Creating it.
UUserWidget* MyHelpTextHUD;
// .cpp file
if (HelpTextHUD) // Check if the Asset is assigned in the blueprint.
{
// Create the widget and store it.
MyHelpTextHUD = CreateWidget<UUserWidget>(GetWorld(), HelpTextHUD);
// now you can use the widget directly since you have a referance for it.
// Extra check to make sure the pointer holds the widget.
if (MyHelpTextHUD)
{
//let add it to the view port
MyHelpTextHUD->AddToViewport();
}
}
any help would be appreciated thanks!!