Problem with setting room custom properties

Options
hi guys :)

i implemented a room timer that is based on the photon network.time but it seem to have some one last issue.

the problem is that in lobby i get different time then in room so whenever a room is created the photonnoetwork.Time is re sampled by the code and set to the room custom properties as starting time.

the problem is that once I'm a while that value isn't updating fast enough and a user might join and won't see the starting time.

so what i was thinking of is to set the room as invisible and after creation when setting the start time in custom properties, then also making the room visible.

im not sure this is the right way. any other ideas?
or maybe photon have some service of getting utc time?

Comments

  • vadim
    Options
    Hi,
    Looks like this is the only way to set room property to photonnoetwork.Time
    But I don't understand how you use it for timer. This time makes sense within room only.
  • guyhazi
    Options
    sorry for the late replay but il write my timer logic for future generation ;)

    once a player enter the room:
    if player is master client and the room property "timer" doesn't exist he set it up as photon network time.

    if a player isn't master client and the room property is null , a coroutine start and a while loop wait 1 second while "timer" is null - once its not null the code parse it and use it as timer.

    if a player isn't master client and the room property is NOT null then the code parse it and use it as a timer.

    the "timer" is actually the time that the property was set up and the players have a constant that represent the seconds of a game round.

    once it passed 50% of it the master client check if the room is invisible and if not he set it as invisible so other players won't join when there is low game time left.

    once a master client has changed he check the above phase.

    when time is up all players leave room and continue the game "loop"

    eventually the room is empty and closed.

    the total game time is 180 seconds and no problems found yet :) hopefully photon won't change it because then I'm in big trouble :).

    if you want to see the game itself and how it work you can search tiny jetpack shooters on iOS or android

    good luck
  • vadim
    Options
    guyhazi said:

    hopefully photon won't change it because then I'm in big trouble
    good luck

    What part of Photon that not to be changed you worry about? While constantly working on new features, fixes and enhancements, we try to keep existing api intact. Breaking changes are rare and could be easily adapted by your project. So you may run into trouble only if using some undocumented behavior.
  • guyhazi
    Options
    vadim said:

    guyhazi said:

    hopefully photon won't change it because then I'm in big trouble
    good luck

    What part of Photon that not to be changed you worry about? While constantly working on new features, fixes and enhancements, we try to keep existing api intact. Breaking changes are rare and could be easily adapted by your project. So you may run into trouble only if using some undocumented behavior.
    currently I'm using the photonnetowrk.time, and as i understand it the server time since last reboot?
    when that "time" value will change to something else i might have some problems, if the new value have a different digit that represent the seconds, like utc time and utc time with milliseconds, there are different place for the digit that represent the seconds.
  • vadim
    Options
    We do not plan change PhotonNetowrk.time behavior or too many existing apps would break.
    Note that this time wraps every ~49 days. So only delta time (between times within 49 days) makes sense, not absolute value.
  • guyhazi
    Options
    vadim said:

    We do not plan change PhotonNetowrk.time behavior or too many existing apps would break.
    Note that this time wraps every ~49 days. So only delta time (between times within 49 days) makes sense, not absolute value.

    i have a question about that, what exactly happens on that moment? the time change to 0?or the room get closed because the server restart? or any thing else?
    currently the game settings closes the room after 150 seconds passed and make it invisible after 75 second has passed, also the room get closed if the time is smaller than the start time minus 30 seconds, does this method handle the photon time reset properly enough or do you have a different approach for that? i don't really mind if the room get closed once every a large amount of days.
  • vadim
    Options
    Nothing happens except PhotonNetowrk.time wraps to 0.