Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Synchronize Start of a game between 500 players

Discussion in 'Multiplayer' started by romain_mozer, Feb 8, 2019.

  1. romain_mozer

    romain_mozer

    Joined:
    Jan 22, 2019
    Posts:
    3
    Hi !
    I'm working on a game where i need 500 players to start at a specific hour.
    My approach so far:
    It rely on a server with a mysql database.
    I have a table "gamestate", where i set boolean at specific times (start_game, display_score, etc...)
    To start these events on specific time, i use mysql Event Scheduller.
    The problem is i can't rely on them. They sometime happen several minutes late...

    Does anyone has an idea on how to achieve this?

    This is not real multiplayer. I just need to synchronize things at some points in game.

    Thanks for all
     
  2. g_a_p

    g_a_p

    Joined:
    Mar 16, 2015
    Posts:
    279
    Using SmartFoxServer this could be easily achieved, but I suppose it would be an overkill to pay for a license ( although only 25€/month) just for this feature.
     
  3. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,754
    What networking solution you are using. Is it TCP/UDP or just web request?
     
    Joe-Censored likes this.
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    This ^^^

    If you're connecting all players to a central server via TCP/UDP, you'd just have the server send a message to all the clients at the appropriate time for each event. Then your clients would only be off from each other by whatever their network latency is, which is generally a negligible amount of time for something like starting a game (some low fraction of a second). If even that were unacceptable, you'd have to come up with a more complicated solution involving scheduling based on a central time source.
     
    Antypodish likes this.
  5. romain_mozer

    romain_mozer

    Joined:
    Jan 22, 2019
    Posts:
    3
    Hi, thanks for all your answers. actually, i'm using web requests. All my players send a webrequest at a given interval (4 seconds) and check the GameState (Playing, Wait other players, Display Score, etc....).
    The state change on time with mySQL event scheduler. For exemple : at 12:00 -> GameState = Start Game, at 12:00:30 -> Display Score, etc...
    That's what is synchronizing my game for now.

    I'm not used to TCP/UDP. Is it easy to implement with Unity?
     
  6. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    If you are doing it that way then you'll have to accept client starts off by up to around 4 seconds.

    No, networking is one of the more difficult topics in game development (not specific to Unity).
     
  7. romain_mozer

    romain_mozer

    Joined:
    Jan 22, 2019
    Posts:
    3
    Yes that's not a problem. I don't need players to be synchronised during all game. I just need them to know when it starts, and when it ends.