Trouble trying to track how many hours the game has been off using DateTime structs

Hello all,

I need your help with the following:

I want the player’s lives to be “refilled” one by one every hour (wether the game is being played or not), as long as it’s under the number of max lives.

Since I am using different levels with different game modes, I have all my save game logic set up in the game instance. I am using it to record the UTC time when the player quits the game and compare it to the UTC time the game starts up again, so I can get the difference in hours and, for every hour the game has been off, add a life to the player life count until it reaches it’s max cap.

What happens is that instead of getting the amount of hours the game has been off, I get the following:

the date time the game was relaunched minus the following date time:…etc; instead of the date time when the game was closed. And it IS being recorded and saved, since the variable for the time the player left is being updated correctly, but when I try to subtract it from the time the game was started again instead of using the correct value it uses the aforementioned…etc.

I first tried using the subtract node to get a timespan from the two Date Time struct variables and had the problem, then I tried manually converting each date time to hours and just doing int-int; but when I debug, the subtraction always provides a huge number because the subtrahend is coming from that default year one date instead of the proper date time the game was closed. Again, the properly saved exit time is recorded and updated, but replaced by 01.01.00 etc when I try to get the interval…

On the other hand I have a function to keep track of time while the game is running and add a life at the turn of the hour, which has no issues atm, though I haven’t tested to see what happens when the hour changes, but it should be fine.

I also haven’t waited yet for a few hours to see if the subtrahend date time being changed to 01.01.00 is only because less than one hour has gone by yet, if that may be what matters…

So if anyone knows what I need to do to achieve what I need to keep track of the time that elapses between game close and game relaunching, I appreciate your help.

Then another little problem I seem to have in the same part of the graph is a False Boolean result from a branch that should yield True, since I am comparing to see if one variable’s value is less than the others and it absolutely IS (2 current lives out of the 3 max lives), but instead of giving True it gives False. When it is true, the amount of lives per hour elapsed has to be added to the player’s life count. It is saying that 2 is not less than 3 and therefore won’t go on with the addition (although it would now add like 17000 something because it is not giving the correct time data). Could it all be because an hour still hasn’t elapsed or is there something else here I need to know?

Thank you all in advance

Here are my graphs: