"CreateWidget can only be used on UUserWidget children" error on a class that inherits from UserWidget

Hi there!

Getting an error during gameplay when CreateWidget needs to be called.
“PIE:Error: Error CreateWidget can only be used on UUserWidget children.”

What’s happening here is that during a executed console command (“TestCombat”) it calls up the and creates the combat UI (attack, target selection, etc) using this line from the game’s game mode script.

CombatUIInstance = CreateWidget<UCombatUIWidget>(GetGameInstance(), CombatUIClass)

In it’s header CombatUIInstance and CombatUIClass are defined as

UCombatUIWidget* CombatUIInstance

UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "UI")
TSubClassOf<class UCombatUIWidget> CombatUIClass;

Now the CombatUI widget blueprint that it’s supposed to spawn, it’s parent is CombatUIWidget.

Inside the CombatUIWidget class header, the class declaration is UCLASS(Blueprintable) class GAME_API UCombatUIWidget : public UUserWidget, public IDecisionMaker { // variable and function declaration stuff };

So now you see that the widget it’s trying to create does indeed inherit from UUserWidget (as far as I can tell) so I’m pretty stumped as to how on earth to proceed haha

Anyone had a similar issue?

(P.s. I’ve looked at both C++ widget extending tutorials on the wiki and it’s basically the same method as what I’ve been doing, with no luck)

Hey robert-alphawave,

There was a similar question yesterday from a different user. Here is a walk through of extending UUserWidget:


Um…that link seems to redirect back here. haha