Hi all!
I am found a strange bug in the function GetWorldTimerManager::GetTimerElapsed. This function is returning negative value, and it is not a -1. The code for reproducing this bug is below.
TimerActor.h
UCLASS()
class TESTPROJECT_API ATimerActor : public AActor
{
GENERATED_BODY()
public:
FTimerHandle timer;
virtual void BeginPlay() override;
void TimerFunction();
};
TimerActor.cpp
#include "TestProject.h"
#include "TimerActor.h"
void ATimerActor::BeginPlay()
{
Super::BeginPlay();
GetWorldTimerManager().SetTimer(timer, this, &ATimerActor::TimerFunction, 0.01f, true);
}
void ATimerActor::TimerFunction()
{
float elapsed = GetWorldTimerManager().GetTimerElapsed(timer);
auto message = FString::Printf(TEXT("%f"), elapsed);
GEngine->AddOnScreenDebugMessage(-1, 0.01f, FColor::Red, message);
}
The results are on the image below.
Looks like error in this function (I placed red numbers with debug information):