Hey all,
I want to add a widged over my AI Character, but there are some some problems, when i try to compile the code:
Error E:\UE4\CProject01\Source\CProject01\The_Character.cpp(47) : error C2665: "CreateWidget": Durch keine der 3 ?berladungen konnten alle Argumenttypen konvertiert werden.
Info C:\Program Files (x86)\Epic Games\4.12\Engine\Source\Runtime\UMG\Public\Blueprint/UserWidget.h(1083): note: kann "T *CreateWidget<UUserWidget>(UGameInstance *,UClass *)" sein
Info with
Info [
Info T=UUserWidget
Info ]
Info C:\Program Files (x86)\Epic Games\4.12\Engine\Source\Runtime\UMG\Public\Blueprint/UserWidget.h(1039): note: oder "T *CreateWidget<UUserWidget>(APlayerController *,UClass *)"
Info with
Info [
Info T=UUserWidget
Info ]
Info C:\Program Files (x86)\Epic Games\4.12\Engine\Source\Runtime\UMG\Public\Blueprint/UserWidget.h(1004): note: oder "T *CreateWidget<UUserWidget>(UWorld *,UClass *)"
Info with
Info [
Info T=UUserWidget
Info ]
Error E:\UE4\CProject01\Source\CProject01\The_Character.cpp(*) : note: bei Anpassung der Argumentliste "(AEye_Character *const , TSubclassOf<UUserWidget>)"
This is my code in The_Character.h file:
#pragma once
#include "GameFramework/Character.h"
#include "The_Character.generated.h"
UCLASS()
class CPROJECT01_API The_Character : public ACharacter
{
GENERATED_BODY()
public:
// Sets default values for this character's properties
The_Character();
virtual void BeginPlay() override;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MyWidget")
TSubclassOf<class UUserWidget> WidgetClass;
// Variable to hold the widget After Creating it.
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MyWidget")
class UUserWidget* MyWidget;
};
And here is the The_Character.cpp file:
#include "CProject01.h"
#include "The_Character.h"
#include "Blueprint/UserWidget.h"
void The_Character::BeginPlay()
{
Super::BeginPlay();
if (WidgetClass) // Check if the Asset is assigned in the blueprint.
{
if (!MyWidget)
{
MyWidget = CreateWidget<UUserWidget>(this, WidgetClass); // Create Widget
if (!MyWidget)
return;
MyWidget->AddToViewport(); // Add it to the viewport so the Construct() method in the UUserWidget:: is run.
}
}
}
As you can see the problem is the CreateWidget Function. Any ideas?
PS.: Sorry that the error code is in german, but i dont know how to change this either.