DeltaTime is not right

Hey guys,

I wanted a timer displaying in my console, which Shows how many seconds passed since the start of my game.
The Problem is that:

void SomeActor::Tick(float DeltaTime){ 
    Super::Tick(DeltaTime);
    static float RealTime = 0;
    RealTime += DeltaTime;
}

doesnt give me the Real Time passed since the start.
I tried a bunch of stuff and I noticed that DeltaTime is 5 times the RealTimeDelta.

void AShowroomProduct::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
	static int i = 0;
    static Time = 0;
	static float FalseTime= 0;

	if (i == 0)
	{
		i++;
        //Global Variable (Initialized with 0)
		LastFrameTime = GetWorld()->GetRealTimeSeconds();
	}
	float RealDelta = GetWorld()->GetRealTimeSeconds() - LastFrameTime;
 
    LastFrameTime = GetWorld()->GetRealTimeSeconds();

	Time += RealDelta;

	FalseDelta += DeltaTime;
	UE_LOG(LogTemp, Warning, TEXT("Realtime Delta: %f\nTime till Start: %f\nStandardDelta: %f\nDeltatime Till Start: %f"), RealDelta, Time, DeltaTime, FalseDelta);
}

Heres a Picture of the log:

88581-log.png

Thanks

Greetings

Hello,

  • Where is FalseDelta being declared? It’s possible I’m overlooking it, but I don’t see a declaration for it.
  • Do you have a test project that we can use to reproduce this on our end, or can you provide the code files if they do not contain references to other files that you’ve created? You can PM me on the forums with a link to Dropbox where I can download the project/files: https://forums.unrealengine.com/member.php?160394-Sean-Flint

Hey,
sry that’s the static variable FalseTime. I “coded” this example in here so I made a Little mistake :stuck_out_tongue:
Unfortunately I can’t provide my code files because they contain things I cannot share.
And I can’t really think of a way to reproduce this error.

Thank you

Edit:
I just tried it out and it works now. Maybe there was a Little bug :confused:
Maybe “stat fps” could be a factor.
But now I tried it too with “stat fps” enabled and it worked fine.
Or I “miscalculated” the real time. (I dont’ think so)

Ok I’m stupid.
I knew I oversaw something xD
I made the variable static in the Tick. But I had 5 Instances of this Object currently in the World :smiley:
Now it makes sense why the timer was 5 times fast than Realtime.

Sry for that ^^