Is it possible to get the time since the room was made ?

Options
Hi all,

Is there a way to get the time since the room was made ?
I need it to syncronize my creeps waves when the masterClient leaves the game.

Thx

Comments

  • Could you not just start a basic timer ? And use the values of that? Something like this maybe....
    float timer = 0;
    
    void Update()
    {
         timer += Time.deltaTime;
         if(timer => 300)
         {
               WaveSpawn();
               timer = 0;
         }
    }
    

    Would something simple like this not work for you? :)
  • Paradoks
    Options
    thx for the answer, but my problem is : cant let the clients/players make the timer as they will probably not connect at the same time.
    so if the master client leaves and the second has connected 30sec later the game, the timer will not spawn at +45 but +15, thats why i need a way
    to get a room oriented timer.
  • vadim
    Options
    Hi,

    Take a look at InRoomRoundTimer.cs located in PUN UtilityScripts folder.
    It uses PhotonNetwork.time property.
  • Paradoks
    Options
    Hi,

    i do that :
    void Start(){
    beginningPhotonTime = (int)PhotonNetwork.time;
    }
    void Update(){
    timeSinceBegining = (int)(PhotonNetwork.time - beginningPhotonTime);
    }

    I hope it helps someone else.
  • Tobias
    Options
    You will need to sync that value. In the InRoomRoundTimer.cs, we put such a value into the room properties.
    When another player joins quickly after creating the room, then the property is maybe not yet set. So make sure your client reacts to newly-set properties and re-checks it's local time.