Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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:; 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

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:

alt text

alt text

alt text

Product Version: UE 4.20
more ▼

asked Aug 24 '18 at 07:40 AM in Blueprint Scripting

avatar image

3 1 2 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question