Using FPlatformTime for any in-game stuff is quite a bad idea for one specific reason. If you pause the game or use some time dilation effects, FPlatformTime doesn’t care about those and just keeps going while your game time is paused or slowed. I think it’s worth mentioning in the lesson.
Good point!
I even wonder if this works reliably on other platforms? Personally I switched back to game time
Alternative: Timer functions via FTimerHandler.
A c++ example: http://www.tomlooman.com/using-timers-in-ue4/
I agree, this is just an option for you to introduce the high precision timer in case you need it.
The link you posted is broken this is the correct one.
thanks, edited my post
This is an interesting thread. Unfortunately, for some reason I can’t find any documentation on FPlatformTime in the Unreal docs.Does anyone have a link for that as well?
From looking at the implementation I reached the following conclusions:
I believe that they didn’t document FPlatformTime due to its nature, it’s platform specific and therefore every different platform will have a different implementation.
The API is quite clear though:
-
Seconds() give you the number of seconds since an unspecified moment. For example, in Windows FPlatformTime is typedefined as FWindowsPlatformTime and the implementation uses WINAPI’s QueryPerformanceCounter to count seconds in high resolution (<1us).
-
You can also use FPlatform::SystemTime() and FPlatform::UtcTime() to get a formatted date with a specified starting point.
-
Cycles() and Cycles64() give you the number of CPU cycles since an unspecified point (as an int or long long)
Because a solid answer was never really given here, you can use GetWorld()->GetTimeSeconds()
This WILL stop when the game is paused and prevent early reloading or whatever you’re using it for.