I’m trying to build a very simple in-game clock and calendar by using a FDateTime variable to hold the game world’s date and time. In order to increment the in-game clock correctly, each tick I multiply DeltaTime by the game time/world time ratio; if I want 2 seconds to pass in-game for every second in real-life I multiply the delta by 2, if I want a full minute to pass for each real-life second I multiply it by 60:
float adjustDelta = DeltaTime * gameSecondsPerWorldSecond; //convert real time into game time
dateTime += adjustDelta; //Add the adjusted delta to my FDateTime variable
debugSec = dateTime.GetSecond(); //Drop the HH:MM:SS values to public variables so I can monitor their value in the inspector
debugMin = dateTime.GetMinute();
debugHour = dateTime.GetHour();
This compiles cleanly, but when I run it and view my debug floats in the inspector, all three remain at 0 and never increment. My assumption is that the mistake lies in trying to add a float to an FDateTime, but since the compiler didn’t produce a type mismatch I’m not really sure what I should be changing to properly increment time.
Hmm okay… how would I manually add seconds/minutes/whatever to NewDate, to ensure I’m not just adding a blank date to my existing one? Playing with intellisense shows me getters for each individual field, but I can’t seem to find setters.
Okay, so I figured out that I’m supposed to use a timespan instead of adding two DateTimes, but that still doesn’t seem to work with deltatime; the following never advances the seconds, minutes, or hours: