I’m trying to work out a way to use an FDateTime variable as my in-game clock, by taking the DeltaTime every tick, multiplying it by whatever real time/game time conversion factor I want, and adding that to the FDateTime. I’ve already gathered that you modify datetime objects with FTimeSpan, so I expected the following to work:
The above code never advances the clock, which initially made me assume that I simply couldn’t work in milliseconds. However, the following change does work, and as far as I can tell it causes the clock to keep correct time:
However, I’m hesitant to use it without understanding it- DeltaTime is a float that measures the time between frames, shouldn’t I be processing it as milliseconds, not seconds?
No, [FONT=Courier New]DeltaTime is actually the time since the last tick in seconds. The documentation for some overloads of [FONT=Courier New]Tick indicates this by using [FONT=Courier New]DeltaSeconds as parameter name, see, e.g., [FONT=Courier New]AActor::Tick](https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/AActor/Tick/1/index.html). You can also check this by comparing your tick delta with the difference between the wall clock times of the previous and current frame:
LogTemp: Ticking: Delta Time = 0.008333, Elapsed Time = 8ms
LogTemp: Ticking: Delta Time = 0.008333, Elapsed Time = 8ms
LogTemp: Ticking: Delta Time = 0.008333, Elapsed Time = 9ms
LogTemp: Ticking: Delta Time = 0.008333, Elapsed Time = 8ms
LogTemp: Ticking: Delta Time = 0.008333, Elapsed Time = 8ms
LogTemp: Ticking: Delta Time = 0.008333, Elapsed Time = 9ms
LogTemp: Ticking: Delta Time = 0.008333, Elapsed Time = 8ms
LogTemp: Ticking: Delta Time = 0.008333, Elapsed Time = 8ms