Variables, Timers, and Events tutorial not working in 4.7.6

Using the sample code from

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

I was not able to reproduce the results shown when executing the code. The instance of the CountdownTimer has no root component according to the editor.

Hi rogueyoshi,

Are you sure that you are selecting the correct object and looking at the right area? I followed along with the tutorial and noticed that as part of the first step, the code was added:

CountdownText->AttachTo(RootComponent);
RootComponent = CountdownText;

This should add the Root component. After doing all of the code in the first part of this tutorial, you should be able to click the C++ class in the editor and drag it into the world. After doing so, click on the object itself in the world (Or in the World Outline) and then it should show the root component as part of the details on the right side of the screen.

If you don’t see the things below, the issue is most likely in the code itself. If this is the case, could you copy and paste your .cpp and .h file? Attaching them would be alright as well.

i followed step by step too to no avail but i have not tried again since i forgot about your response. i will make a recording of my attempt if i have an issue with retrying.

Hi rogueyoshi,

Did you find the solution to your issue? For tracking purposes, I’ll be marking this post as resolved. If you still require assistance, please feel free to comment and I’ll assist you further.

Have a nice day,

Hi rogueyoshi,

Have you found the solution to your issue? Once again, due to the amount of time, I’ll be marking this issue as resolved. Please feel free to comment if you require more assistance and the question will reopen.

I am have the exact same issue. I’m pasting my code.

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();

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

// Called every frame
virtual void Tick( float DeltaSeconds ) override;

int32 CountdownTime;

UTextRenderComponent* CountdownText;

void UpdateTimerDisplay();

void AdvanceTimer();

void CountdownHasFinished();

FTimerHandle CountdownTimerHandle;

};

Countdown.cpp

#include “HowTo_VTE.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);
CountdownText->AttachTo(RootComponent);
RootComponent = CountdownText;

CountdownTime = 3;

}

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);
CountdownHasFinished();
}
}

void ACountdown::CountdownHasFinished()
{
//Change to a special readout
CountdownText->SetText(TEXT(“GO!”));
}

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

}

Sorry for the double post, Chrome seems to be struggling with this site these days …

So, after two hours Unreal crashed, restarted, and automagically the code worked perfectly. That may not be of any help to anyone ever but there’s your fix. Just crash it.

Hello CoffeeHerald,

I took care of the double post, Answerhub was having some hiccups earlier. If this issue presents itself again, please let me know and we can try to find the root cause.