Issue with Timer Tutorial

https://docs.unrealengine.com/latest/INT/Programming/Tutorials/VariablesTimersEvents/1/index.html

I’m currently trying to accomplish this tutorial (new to Unreal) and I attempted to declare the UTextRenderComponent pointer but it says the class is undefined. I found elsewhere that one solution is to include engine.h, however when I do that ‘UCLASS()’ and ‘class’ get underline errors.

I have copied the code exactly as from the tutorial, so what is the issue?

Thanks!

Hello dizzykiwi3,

Declaring the UTextRenderComponent shouldn’t be giving you any compilation errors. I’ve just tested it myself in 4.10.2 without any problems. Could you post the code and the Output Log (not the Error List) from when you attempt to compile?

Please be aware that the underline “errors” are not actual errors but things that Intellisense isn’t able to make sense of. This is a common problem with UE4 as Intellisense isn’t able to see somethings that UE4 does under the hood and gives false errors such as this. It shouldn’t prevent you from compiling.

Header Code

// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.

#pragma once

#include "GameFramework/Actor.h"
#include "Countdown.generated.h"

UCLASS()
class TESTPROJECT_API ACountdown : public AActor
{
	GENERATED_BODY()

public:
	// Sets default values for this actor's properties
	ACountdown();

	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

	// 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;
};

CPP code

// Fill out your copyright notice in the Description page of Project Settings.

#include "TestProject.h"
#include "Countdown.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!"));
}

Log

I pasted the code below

Thank you for providing the code. I’m continuing to look into this but I will say that I am initially confused. I’ve copied and pasted the code you provided directly into a fresh class that I made with no compiling errors. I know you listed “4.10” as your product version, but are you on 4.10, 4.10.1 or 4.10.2?

We haven’t heard from you in a while, dizzykiwi3. Are you still experiencing this issue? If so, could you answer the question from my previous comment? In the meantime I’ll be marking this issue as resolved for tracking purposes.

Hi, I am also experiencing this problem with 4.9.2
I have an old project where it worked fine, but i’ve just re-opened it and is now giving me errors with it as well (as I am currently trying to do the same in another project)

UTextRenderComponent* m_tDamageText;

Hello Lloyd,

What type of messages are you getting from your output log when you attempt to compile? It should help narrow down the problem. Sometimes VS will point to a line of code while it has nothing to do with the actual problem.

We haven’t heard from you in a while, dizzykiwi3. Are you still experiencing this issue? Knowing the exact version you’re using would be helpful as the changes between them could be affecting this. In the meantime, I’ll be marking this issue as resolved for tracking purposes.

Hello , I have the very same problem as op and it’s a pity there was no solution found as the question was dropped. I have posted more details from the output log in my post Unknown type name 'UTextRenderComponent' while following tutorial - Pipeline & Plugins - Epic Developer Community Forums
I hope you can help

To whomever it may concern, the solution is in the above link. Thanks to a kind user. I hope this will be useful to someone like me who spent half a day looking in vain for a solution.

This code needs to be updated. I’m getting all sorts of errors.