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"

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 red underline errors.

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

Thanks!

Product Version: UE 4.10
Tags:
more ▼

asked Jan 26 '16 at 08:25 PM in C++ Programming

avatar image

dizzykiwi3
1 2 4

avatar image Matthew J Jan 26 '16 at 08:59 PM

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 red 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.

avatar image dizzykiwi3 Jan 26 '16 at 10:45 PM

I pasted the code below

avatar image Matthew J Feb 02 '16 at 06:38 PM

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.

avatar image Lloyd Phillips Feb 10 '16 at 02:25 PM

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;

avatar image Matthew J Feb 10 '16 at 02:47 PM

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.

avatar image leadermax Nov 30 '17 at 05:26 PM

Hello Matthew, 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 https://answers.unrealengine.com/questions/730971/unknown-type-name-utextrendercomponent-while-follo.html I hope you can help

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

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.

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

2 answers: sort voted first

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

output log.txt (4.5 kB)
more ▼

answered Jan 26 '16 at 10:44 PM

avatar image

dizzykiwi3
1 2 4

avatar image Matthew J Jan 29 '16 at 01:26 PM

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?

avatar image Doctor_Kannon Sep 08 '18 at 12:40 AM

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

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

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.

more ▼

answered Feb 16 '16 at 03:56 PM

(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