TSubclassOf returning null

So I am trying to move my widgets into C++ and a HUD. I have tried watching a tutorial to get this set up though it doesn’t seem to be working for me. I set my widgets in the HUD BP using TSubclassOf and then select them in the BP itself, yet everytime I run the game I get my UE logs trigger telling me its null.

UPROPERTY(EditDefaultsOnly, Category = "Widgets")
TSubclassOf<UUserWidget> CombatStatusWidgetClass;

UPROPERTY(EditDefaultsOnly, Category = "Widgets")
TSubclassOf<UUserWidget> EnemyInfoWidgetClass;

Here is my cpp implementation.

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

	if (CombatStatusWidgetClass)
	{
		CreateCombatStatusWidget();
	}
	else
	{
		UE_LOG(LogTemp, Error, TEXT("Issue with CombatStatusWidgetClass"));
	}

	if (EnemyInfoWidgetClass)
	{
		CreateEnemyInfoWidget();
	}
	else
	{
		UE_LOG(LogTemp, Error, TEXT("Issue with EnemyInfoWidgetClass"));
	}
}

Tried setting both the class and the BP and getting the same result each time. I know the HUD is getting called as well as BeginPlay because I am getting my errors, it is just having issues setting these attributes for some reason.

1 Like

Figured it out. In my game mode override I set the class version of the HUD, not the blueprint version. Due to that it wasn’t finding my set classes.

1 Like