Search Unity

Using 'Real Time' to simulate time of day in-game

Discussion in 'Scripting' started by hawx, Nov 30, 2013.

  1. hawx

    hawx

    Joined:
    Sep 29, 2012
    Posts:
    95
    Hi,

    I'm not too sure how to start this piece of code I'd like to work on. I'd like to use real-time so that the user experiences that in game - so 18:42pm in real life would be 18:42pm in game.
    I'm not too sure how to do this - I have searched on google but it didn't come up with any 'helpful' results.

    Thanks,
    Hawx
     
  2. Hikiko66

    Hikiko66

    Joined:
    May 5, 2013
    Posts:
    1,304
    Code (csharp):
    1. DateTime.Now.ToString("HH:mm:ss tt")
    gives you the system time in C#
    You will need to add a reference to System

    Simulating daylight would be much more difficult, as that is region specific and changes throughout the year.
     
    Last edited: Nov 30, 2013
  3. hawx

    hawx

    Joined:
    Sep 29, 2012
    Posts:
    95
    Thanks for the start, I'll just need to translate it to UnityScript and then I can work from there.

    Thank you,
    Hawx