Keeping track of time while the game is closed

Hi :slight_smile:

I want to be able to use Visual Scripting to keep a timer running regardless of scene changes and especially while the game is closed. This is to enable tracking of duration for tasks that take time, plus the passage of days etc.

I’ve found references to using .NET DateTime info - but I don’t know how to apply that.

There doesn’t appear to be a visual scripting node/function to enable, for example, getting system time or real-world UTC time. As far as I can tell there were some nodes in Bolt but they’ve been removed or have changed names.

I figure this must be a really common function used in idle games, task-queue and building games etc.

Can anyone point me in the right direction?

Thanks so much,
Canley

My latest thinking on this is that perhaps I need to enable or import some .NET stuff? Perhaps there is a System.DateTime node or data type that only becomes accessible if I add a package?

I’ve checked my Player settings (Project Settings\Player\Configuration), and they are at Mono & .NET Standard 2.1

My hunch is those settings are correct.

Have spent quite a few fruitless hours on this so far. Still - perhaps this is a bigger .NET problem I have rather than just DateTime?

Solved

Ok so I was looking for a way to access system time - DateTime is the node I needed. But it wasn’t listed in the fuzzy menu.

I found this video by Smart Penguins that explained how to get it in Bolt and Visual Scripting (from around 1:05 in the video).

In summary for VS:

  1. In your open project go to Edit\Project Settings
  2. Click on Visual Scripting in the left-hand menu
  3. Click the drop-down arrow for Type Options
  4. Scroll to the end of the list and click on the plus sign on the right-hand side
  5. Click on “No Type” and search for “DateTime (in System)” and select it
  6. Scroll down to “Regenerate nodes” and click - wait for it to run
  7. In your VS graphs you can now right-click on the graph and search for Date Time nodes such as Date Time Get Now

Many hours searching for this solution - hope it’s of use to others also.

Cheers,
Canley

did you figure out how to get the time in between application on and off?
if you havent i just recently learned how and could tell you i spent 2 days trying to solve this

Thank you yes I did. Now I am able to add date time nodes I just add the task start time (real world time) to a saved variable then track its remaining time. If the app is closed when the timer runs out it just sorts out once the app runs.

You, sir, are a scholar and a gentleman

Ha, thank you so much! Sorry only just saw your reply 2 years later smh! :melting_face: