Possible ways to make Round time server based?

Options
Hey
The title being a vague question, I would like to summarize the current situation of our work. We are working on a multiplayer game that we are making focusing on competitions. While our game is pretty much at a stable state we reached a problem that we cant understand. Now the problem consists of 2 things but this question only relates to one of them.

Our spawning of players & objectives take place depending on 3 different timers each written with Mathf.movetowards method. 1st timer(10 sec) is to introduce round, 2nd timer(25 sec) is to select the loadout & the 3rd timer(5 min) is the round duration. Now so far it works as follows
        public int RoundDuration = 300;
        public int PrepPhase = 25;
        public int RoundIntro = 10;

        public int currentRoundDuration ;
        public int currentPrepPhase;
        public int currentRoundIntro ;

        void Start(){
           public int currentRoundDuration = RoundDuration ;
           public int currentPrepPhase = currentPrepPhase;
           public int currentRoundIntro = currentRoundIntro;
        }

       void FixedUpdate(){
         if(currentRoundIntro == 0){
               if(currentPrepPhase  == 0){
                     currentRoundDuration = Mathf.MoveTowards(currentRoundDuration , 0, Time.deltaTime);
               }else{
                     currentPrepPhase   = Mathf.MoveTowards(currentPrepPhase  , 0, Time.deltaTime);
              }
          }else{
              currentRoundIntro = Mathf.MoveTowards(currentRoundIntro , 0, Time.deltaTime);
         }
       }

I have seen few posts talking about using PhotonNetwork.Time but not sure how that works and how I can get it to work in this case. :/ any help please

Comments

  • jeffries7
    Options
    Photon.Time looks like a fairly straight forward route, just remember to take into account that it wraps. Other options are using an RPC from the server to notify each client when moving between timers, then each client calculates their time locally.
  • Meheraj7
    Options
    Photon.Time might also cause the same issue as I have to recheck it after every round ends, because a round can also end without having to completely timeout. But we have several rounds around 13-24 so i still dont see a way to make that work.

    The problem is if a host leaves it takes around 20 seconds for photon to migrate to the new host and delete the previous host's entities. Now that makes calling anything in relation to timer is not viable at all, as the whole time the host's data is being destroyed the timer gets stuck until the previous host is completely removed from the room

    How do I call RPC from the server and not the host? because at the end of the day it is the same issue with host.it wont get called in time if host is leaving.
  • jeffries7
    Options
    Regarding host migration, you'll have to build in a system that pauses timers whilst a new host is found if you want to use Photon.Time
    IInRoomCallbacks.OnMasterClientSwitched
    

    Also, consider room properties for the current room state. This means when a new host is assigned then the previous state isn't lost.

    Personally, I'd run the timers locally with an RPC to switch to new states. If a host leaves during a countdown then there is the potential that the players don't even notice and if the migration overlaps with the end of a round then they all just wait.
  • Meheraj7
    Options
    Is there anyway that I can detect if a photon player has stopped receiving/sending data (assuming the player is not responding) ? Then I could switch the host to somone else if timer is stopped?
  • jeffries7
    Options
    If you're going to use photon.time it would automatically get transferred to the newly selected host.
    Do your timers need to be so precise that you need to use photon.time?