Variables, Timers, and Events tutorial

Link to the tutorial: Variables, Timers, and Events

While going through the tutorial, this line of code has been giving me issues:



UTextRenderComponent* CountdownText;


Code:

Compile Issues:

I found some other examples that use this instead, which compiles:



TSubobjectPtr< class UTextRenderComponent > CountdownText;


I am mostly just curious if this is a known issue or maybe I am doing something wrong that I do not understand.

Thanks

– Further reading says that TSubobjectPtr is deprecated. So I must be missing something.

I figured this out.

I had to include Engine.h to my Actor header file.

I also had to change the FString::FromInt( ) calls to, FText::AsNumber( ) and TEXT( ) to, FText::AsCultureInvariant( ) for UpdateTimerDisplay( ) and CountdownHasFinished( ), in that order.

When you create a project, it should create a header file with your project name “ProjectName.h”, which includes all the base Header Files (including Engine.h) for the engine to work properly. You should only need to include your ProjectName.h file into your classes (which is done automatically with the Create a Class Wizard in the editor).

I used the Create a Class Wizard, this is what gets generated:

Just had the same issue when doing the tutorial, managed to solve it by adding the following to CountDown.h


#include "Components/TextRenderComponent.h"