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"

unknown type name 'UTextRenderComponent' while following tutorial

I'm following this tutorial and I literally copied and pasted the content of Countdown.h and Countdown.cpp.

Visual Studio Code (I'm on mac) gives the following hint

 #include errors detected. Please update your includePath. IntelliSense features for this translation unit (/Users/massimobortolamei/Documents/Unreal Projects/HowTo_VTE/Source/HowTo_VTE/Countdown.h) will be provided by the Tag Parser.
 cannot open source file "new" (dependency of "GameFramework/Actor.h")

at this line

 #include "GameFramework/Actor.h"

while the compilation error I get from UE is the following

 Running Mono...
 
 Setting up Mono
 ~/Documents/UE_4.18/Engine ~/Documents/UE_4.18/Engine/Binaries/Mac
 Compiling game modules for hot reload
 Parsing headers for HowTo_VTEEditor
   Running UnrealHeaderTool "/Users/massimobortolamei/Documents/Unreal Projects/HowTo_VTE/HowTo_VTE.uproject" "/Users/massimobortolamei/Documents/Unreal Projects/HowTo_VTE/Intermediate/Build/Mac/HowTo_VTEEditor/Development/HowTo_VTEEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -installed
 Reflection code generated for HowTo_VTEEditor in 10,277899 seconds
 Performing 3 actions (5 in parallel)
 [2/3] Compile Countdown.cpp
 [1/3] Compile Countdown.gen.cpp
 In file included from /Users/massimobortolamei/Documents/Unreal Projects/HowTo_VTE/Intermediate/Build/Mac/UE4Editor/Inc/HowTo_VTE/Countdown.gen.cpp:8:
 ../../../Unreal Projects/HowTo_VTE/Source/HowTo_VTE/Countdown.h:29:5: error: unknown type name 'UTextRenderComponent'
     UTextRenderComponent* CountdownText;
     ^
 ../../../Unreal Projects/HowTo_VTE/Source/HowTo_VTE/Countdown.h:12:5: error: cannot initialize return object of type 'UObject *' with an rvalue of type 'ACountdown *'
     GENERATED_BODY()
     ^~~~~~~~~~~~~~~~
 Runtime/CoreUObject/Public/UObject/ObjectMacros.h:585:29: note: expanded from macro 'GENERATED_BODY'
 #define GENERATED_BODY(...) BODY_MACRO_COMBINE(CURRENT_FILE_ID,_,__LINE__,_GENERATED_BODY);
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Runtime/CoreUObject/Public/UObject/ObjectMacros.h:580:37: note: expanded from macro 'BODY_MACRO_COMBINE'
 #define BODY_MACRO_COMBINE(A,B,C,D) BODY_MACRO_COMBINE_INNER(A,B,C,D)
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Runtime/CoreUObject/Public/UObject/ObjectMacros.h:579:43: note: expanded from macro 'BODY_MACRO_COMBINE_INNER'
 #define BODY_MACRO_COMBINE_INNER(A,B,C,D) A##B##C##D
                                           ^~~~~~~~~~
 note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
 ../../../Unreal Projects/HowTo_VTE/Intermediate/Build/Mac/UE4Editor/Inc/HowTo_VTE/Countdown.generated.h:81:2: note: expanded from macro 'HowTo_VTE_Source_HowTo_VTE_Countdown_h_12_GENERATED_BODY'
         HowTo_VTE_Source_HowTo_VTE_Countdown_h_12_ENHANCED_CONSTRUCTORS \
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ../../../Unreal Projects/HowTo_VTE/Intermediate/Build/Mac/UE4Editor/Inc/HowTo_VTE/Countdown.generated.h:57:54: note: expanded from macro 'HowTo_VTE_Source_HowTo_VTE_Countdown_h_12_ENHANCED_CONSTRUCTORS'
         DECLARE_VTABLE_PTR_HELPER_CTOR(NO_API, ACountdown); \
                                                             ^
 Runtime/CoreUObject/Public/UObject/ObjectMacros.h:1387:11: note: expanded from macro '\
 DEFINE_VTABLE_PTR_HELPER_CTOR_CALLER'
                         return new (EC_InternalUseOnlyConstructor, (UObject*)GetTransientPackage(), NAME_None, RF_NeedLoad | RF_ClassDefaultObject | RF_TagGarbageTemp) TClass(Helper); \
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 In file included from /Users/massimobortolamei/Documents/Unreal Projects/HowTo_VTE/Source/HowTo_VTE/Countdown.cpp:1:
 ../../../Unreal Projects/HowTo_VTE/Source/HowTo_VTE/Countdown.h:29:5: error: unknown type name 'UTextRenderComponent'
     UTextRenderComponent* CountdownText;
     ^
 ../../../Unreal Projects/HowTo_VTE/Source/HowTo_VTE/Countdown.h:12:5: error: cannot initialize return object of type 'UObject *' with an rvalue of type 'ACountdown *'
     GENERATED_BODY()
     ^~~~~~~~~~~~~~~~
 Runtime/CoreUObject/Public/UObject/ObjectMacros.h:585:29: note: expanded from macro 'GENERATED_BODY'
 #define GENERATED_BODY(...) BODY_MACRO_COMBINE(CURRENT_FILE_ID,_,__LINE__,_GENERATED_BODY);
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Runtime/CoreUObject/Public/UObject/ObjectMacros.h:580:37: note: expanded from macro 'BODY_MACRO_COMBINE'
 #define BODY_MACRO_COMBINE(A,B,C,D) BODY_MACRO_COMBINE_INNER(A,B,C,D)
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Runtime/CoreUObject/Public/UObject/ObjectMacros.h:579:43: note: expanded from macro 'BODY_MACRO_COMBINE_INNER'
 #define BODY_MACRO_COMBINE_INNER(A,B,C,D) A##B##C##D
                                           ^~~~~~~~~~
 note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
 ../../../Unreal Projects/HowTo_VTE/Intermediate/Build/Mac/UE4Editor/Inc/HowTo_VTE/Countdown.generated.h:81:2: note: expanded from macro 'HowTo_VTE_Source_HowTo_VTE_Countdown_h_12_GENERATED_BODY'
         HowTo_VTE_Source_HowTo_VTE_Countdown_h_12_ENHANCED_CONSTRUCTORS \
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ../../../Unreal Projects/HowTo_VTE/Intermediate/Build/Mac/UE4Editor/Inc/HowTo_VTE/Countdown.generated.h:57:54: note: expanded from macro 'HowTo_VTE_Source_HowTo_VTE_Countdown_h_12_ENHANCED_CONSTRUCTORS'
         DECLARE_VTABLE_PTR_HELPER_CTOR(NO_API, ACountdown); \
                                                             ^
 Runtime/CoreUObject/Public/UObject/ObjectMacros.h:1387:11: note: expanded from macro '\
 DEFINE_VTABLE_PTR_HELPER_CTOR_CALLER'
                         return new (EC_InternalUseOnlyConstructor, (UObject*)GetTransientPackage(), NAME_None, RF_NeedLoad | RF_ClassDefaultObject | RF_TagGarbageTemp) TClass(Helper); \
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 /Users/massimobortolamei/Documents/Unreal Projects/HowTo_VTE/Source/HowTo_VTE/Countdown.cpp:11:44: error: use of undeclared identifier 'UTextRenderComponent'
     CountdownText = CreateDefaultSubobject<UTextRenderComponent>(TEXT("CountdownNumber"));
                                            ^
 /Users/massimobortolamei/Documents/Unreal Projects/HowTo_VTE/Source/HowTo_VTE/Countdown.cpp:12:43: error: use of undeclared identifier 'EHTA_Center'; did you mean 'kTXNCenter'?
     CountdownText->SetHorizontalAlignment(EHTA_Center);
                                           ^~~~~~~~~~~
                                           kTXNCenter
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Carbon.framework/Frameworks/HIToolbox.framework/Headers/MacTextEditor.h:793:3: note: 'kTXNCenter' declared here
   kTXNCenter                    = 4,
   ^
 /Users/massimobortolamei/Documents/Unreal Projects/HowTo_VTE/Source/HowTo_VTE/Countdown.cpp:22:12: error: cannot initialize object parameter of type 'AActor' with an expression of type 'ACountdown'
     Super::BeginPlay();
            ^~~~~~~~~
 /Users/massimobortolamei/Documents/Unreal Projects/HowTo_VTE/Source/HowTo_VTE/Countdown.cpp:25:5: error: cannot initialize object parameter of type 'const AActor' with an expression of type 'ACountdown'
     GetWorldTimerManager().SetTimer(CountdownTimerHandle, this, &ACountdown::AdvanceTimer, 1.0f, true);
     ^~~~~~~~~~~~~~~~~~~~
 /Users/massimobortolamei/Documents/Unreal Projects/HowTo_VTE/Source/HowTo_VTE/Countdown.cpp:31:12: error: no matching member function for call to 'Tick'
     Super::Tick( DeltaTime );
     ~~~~~~~^~~~
 Runtime/Engine/Classes/GameFramework/Actor.h:2077:15: note: candidate function not viable: no known conversion from 'ACountdown' to 'AActor' for object argument
         virtual void Tick( float DeltaSeconds );
                      ^
 Runtime/Engine/Classes/GameFramework/Actor.h:2432:15: note: candidate function not viable: requires 2 arguments, but 1 was provided
         virtual void Tick( float DeltaTime, enum ELevelTick TickType ) final
                      ^
 /Users/massimobortolamei/Documents/Unreal Projects/HowTo_VTE/Source/HowTo_VTE/Countdown.cpp:47:9: error: cannot initialize object parameter of type 'const AActor' with an expression of type 'ACountdown'
         GetWorldTimerManager().ClearTimer(CountdownTimerHandle);
         ^~~~~~~~~~~~~~~~~~~~
 2 errors generated.
 8 errors generated.
 ERROR: UBT ERROR: Failed to produce item: /Users/massimobortolamei/Documents/Unreal Projects/HowTo_VTE/Binaries/Mac/UE4Editor-HowTo_VTE-6063.dylib
 Total build time: 28,61 seconds (Local executor: 0,00 seconds)
 

It's as if the two errors are related, but I don't get what could be wrong. I noticed that while my project is situated in /Documents/Unreal Projects/HowTo_VTE/Source/HowToVTE/Countdown.cpp the Unreal stuff is in Documents/UE_4.18/Engine/... could this be the culprit for which the include is not found?

edit : Countdown.h

 #pragma once
 
 
 #include "GameFramework/Actor.h"
 #include "Countdown.generated.h"
 
 UCLASS()
 class HOWTO_VTE_API ACountdown : public AActor
 {
     GENERATED_BODY()
 
 public: 
     // Sets default values for this actor's properties
     ACountdown();
 
 protected:
     // Called when the game starts or when spawned
     virtual void BeginPlay() override;
 
 public:
     // Called every frame
     virtual void Tick( float DeltaSeconds ) override;
 
     //How long, in seconds, the countdown will run
     int32 CountdownTime;
 
     UTextRenderComponent* CountdownText;
 
     void UpdateTimerDisplay();
 
     void AdvanceTimer();
 
     void CountdownHasFinished();
 
     FTimerHandle CountdownTimerHandle;
 };


and Countdown.cpp

 #include "Countdown.h"
 #include "HowTo_VTE.h"
 
 
 // Sets default values
 ACountdown::ACountdown()
 {
     // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
     PrimaryActorTick.bCanEverTick = false;
 
     CountdownText = CreateDefaultSubobject<UTextRenderComponent>(TEXT("CountdownNumber"));
     CountdownText->SetHorizontalAlignment(EHTA_Center);
     CountdownText->SetWorldSize(150.0f);
     RootComponent = CountdownText;
 
     CountdownTime = 3;
 }
 
 // Called when the game starts or when spawned
 void ACountdown::BeginPlay()
 {
     Super::BeginPlay();
 
     UpdateTimerDisplay();
     GetWorldTimerManager().SetTimer(CountdownTimerHandle, this, &ACountdown::AdvanceTimer, 1.0f, true);
 }
 
 // Called every frame
 void ACountdown::Tick( float DeltaTime )
 {
     Super::Tick( DeltaTime );
 
 }
 
 void ACountdown::UpdateTimerDisplay()
 {
     CountdownText->SetText(FString::FromInt(FMath::Max(CountdownTime, 0)));
 }
 
 void ACountdown::AdvanceTimer()
 {
     --CountdownTime;
     UpdateTimerDisplay();
     if (CountdownTime < 1)
     {
         // We're done counting down, so stop running the timer.
         GetWorldTimerManager().ClearTimer(CountdownTimerHandle);
         //Perform any special actions we want to do when the timer ends.
         CountdownHasFinished();
     }
 }
 
 void ACountdown::CountdownHasFinished()
 {
     //Change to a special readout
     CountdownText->SetText(TEXT("GO!"));
 }
 



Product Version: UE 4.18
Tags:
more ▼

asked Nov 30 '17 at 04:45 PM in C++ Programming

avatar image

leadermax
55 2 6 16

avatar image Firefly74 Nov 30 '17 at 05:56 PM

could you share the full header file ? ( at least the full includes from begin of file to start of the class )

avatar image leadermax Nov 30 '17 at 06:52 PM

Hi, sorry I'm not sure I understood your question. If you are referring to Countdown.h I have edited my question. Anyway, they are just copied from the tutorial. Thank you for your help.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Try to add "#include "Runtime/Engine/Classes/Components/TextRenderComponent.h"" to your includes in Countdown.h ( juste before the .generated.h, that should always be the last include in .h files in UE

Usually in cases like this, simply look for your component in UE doc and at the bottom of the page, check what is his header file to include it !

( exemple here : https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Components/UTextRenderComponent/ )

more ▼

answered Nov 30 '17 at 10:07 PM

avatar image

Firefly74
1.4k 14 17 31

avatar image leadermax Dec 01 '17 at 08:41 AM

Oh My! It Worked! Thank you very much, I spent half a day looking for a solution ! Any thoughts about why they did not write the include in the tutorial? I also found a guy here with the same problem and the one answering said he tried and had no errors. It's as if I'm missing some crucial basic configuration, maybe in Visual Studio Code. Thank you also for the tip about similar future problems , they are definitely going to bother me again :)

avatar image Matthew J Dec 01 '17 at 02:42 PM

Thanks for providing a solution, Firefly74. The reason this was likely not mentioned in the tutorial is because the default includes that are present when making a new project have changed quite a bit since the tutorial was originally written, mainly when IWYU (Include What You Use) was implemented. This include was most likely part of one of the bulk includes that were previously present. I'll have someone on the documentation team take a look at updating the tutorial.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
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