Search Unity

float to ulong I want to save time player.

Discussion in 'Scripting' started by vistriter, May 28, 2017.

  1. vistriter

    vistriter

    Joined:
    Jan 22, 2017
    Posts:
    91
    I (internetConnected) {
    Get time now from server (ulong.)
    } else {
    Time in game + time at start game
    When start game it's get server time and save (ulong).
    I want to fix this!!
    }


    I want to get time in game. I use function Time.realtimeSinceStart. It return float.

    I can't convert float to ulong. I try to convert float to ulong.

    float timeInGame = Time.realtimeSinceStart.
    ulong timeUlong = (ulong) timeInGame.

    if timeInGame 5 when convert to ulong it's return 5.
     
  2. WarmedxMints

    WarmedxMints

    Joined:
    Feb 6, 2017
    Posts:
    1,035
    Just store the time in a variable on start or awake and when you want to know how long has passed, get the time again and subtract it from the start time. You can do that without the internet time if you wish.