Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Device Independent Date Time

Discussion in 'Scripting' started by jacky-kschou, May 13, 2015.

  1. jacky-kschou

    jacky-kschou

    Joined:
    May 4, 2013
    Posts:
    73
    Hello, I am making a mobile game that allows the player to play offline, and in the game there is a free gift system where player gets a free gift from time to time. So I need to know how many seconds has passed since the player gets a free gift for the system. And I understand that using DateTime.Now would just get the device time so that the player can cheat by setting the device time. Is there anyway to get a device independent time without getting online?

    Thanks
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    No, online is the only way.

    --Eric
     
  3. furic

    furic

    Joined:
    Jul 8, 2013
    Posts:
    13
    Crossy Road seems able to do it. I force quit the game, switch on flight mode, set time become 1 hour later, back to the game and the free gift time still the same!

    How the hell!!!
     
  4. Kazen

    Kazen

    Joined:
    Feb 17, 2015
    Posts:
    68
    I haven't tested Crossy Road and how it works, but maybe if the game isn't played online, the "gift time" stays the same as the time when you closed the game, and updated only when you're online again. This means the "gift time" is only counting down when you're actually playing the game (if you're offline).