Making DeltaTime in FRunnable

Identification
Mon, 25 Mar 2024 08:34:35 +0000
C++

std::chrono::steady_clock::time_point PreviousTime;

//
uint32 FTestThread
{
while(!Stop)
{
		const std::chrono::steady_clock::time_point tClock_Start = std::chrono::steady_clock::now();
		const double DeltaTime = std::chrono::duration_cast<std::chrono::nanoseconds> (tClock_Start - PreviousTime).count() * 10e-9;
		PreviousTime = tClock_Start;

		//Doing something here

		FPlatformProcess::Sleep(0.01);
	}


	return 0;
}

The DeltaTime always remains at 0.

I’ve tried changing the std::chrono::(timetype) and the scalar (1e-9) on std::chrono::duration_cast, but it still returns the same.

Is there anything I should know to make DeltaTime functional in FRuunable?

Please suggest other method or solution

4 posts - 2 participants