C2338 The given OwningObject is not of a supported type for use with CreateWidget. Physics D:\games\unreal\UE_4.24\Engine\Source\Runtime\UMG\Public\Blueprint\UserWidget.h 1429

In BallGenerator.cpp I wrote:

But when I compiled it, it showed errors like:

C2338 The given OwningObject is not of a supported type for use with CreateWidget.

C2665 ��UUserWidget::CreateWidgetInstance��: 5 ��������û��һ������ת�����в�������

But in other tutorials their codes were just like what I wrote. What OwningObject should I use in CreateWidget?

2 Likes

Does BallGenerator derive from UWidget, UWidgetTree, APlayerController, UGameInstance or UWorld ?

As you can see in this screenshot from UserWidget.h, CreateWidget() checks if the owner derives one of these classes.

Also make sure to check the output log to see which class is used as the Owner in CreateWidget().
I thought my UWidget derived class was causing this error because I call CreateWidget() from this class, but the error actually came from my GameNetworkManager class which also called CreateWidget().

5 Likes

Thanks, Its help me~ :smile:
I write it in GameMode file,so its error

You can put GetWorld() instead of this

5 Likes

This worked for me, thank you very much