x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Adding Widged to ACharacter C++

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.

Product Version: UE 4.12
Tags:
more ▼

asked Jul 14 '16 at 04:52 PM in C++ Programming

avatar image

SPP3000
1

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

For you language issue, please google it and find this link HERE. I don't understand why people still don't get it.

For your compilation issue, I guess that one of your arguments is wrong ("can't convert from TYPE1 to TYPE2"). Take a look at UserWidget.h which contains the functions code you are using. You can find it in C:\Program Files (x86)\Epic Games\YOUR_VERSION\Engine\Source\Runtime\UMG\Public\Blueprint\UserWidget.h

Good luck !

more ▼

answered Jul 15 '16 at 08:35 AM

avatar image

NymKappa
692 31 20 54

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question