Download

Some weird error.

Error is in Attachments.

Code propably causing problems:

header:


#pragma once

#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "ShooterPlayerController.generated.h"


UCLASS()
class SEMISIMPLESHITPOST_API AShooterPlayerController : public APlayerController
{
GENERATED_BODY()
protected:
virtual void BeginPlay() override;
private:
UPROPERTY(EditAnywhere)
TSubclassOf<class UUserWidget> HUD;

UPROPERTY()
UUserWidget* HUDScreen;
};

cpp:


#include "ShooterPlayerController.h"
#include "Blueprint/UserWidget.h"


void AShooterPlayerController::BeginPlay()
{
Super::BeginPlay();

HUDScreen = CreateWidget(this, HUD);
if (HUD != nullptr)
{
HUDScreen->AddToViewport();
}
}

Please help

Make sure that you have the proper modules included for your project in the .Build.cs file. For widgets, that would be “UMG”.


PrivateDependencyModuleNames.AddRange(new string] { "UMG" });

Thank you.