Search Unity

Third Party [PhotonCloud] Changing server location at runtime

Discussion in 'Multiplayer' started by shadow-river, Jan 17, 2015.

  1. shadow-river

    shadow-river

    Joined:
    May 29, 2013
    Posts:
    63
    I was wondering if there was a way to be able to change your server location at runtime (using unity UI 4.6)
    I was having problems with massive delay times, had 2 clients running and there was a 1 second delay sending data between them.( for instance the muzzle flash would show on one client then 1 second later show on the next.) I played around with the settings and found that it was because I had it set to EU server location. I set it to AU (since I'm from new Zealand) and that delay was reduced to next to nothing). I realize that most people wont problem have this problem since there internet speeds are a lot faster then ours. but for the people in locations like mine a game with one set server location wont do. so after this long explanation is it possible to set/choose your server location at runtime.

    thanks in advance.
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    PUN can ping all regions for a player and connect to the best. In the PhotonServerSettings file, you can set the hosting type to "Best Region" and connect as before.
    You can also call PhotonNetwork.OverrideBestCloudServer(cloudRegionCode) to override the region before you connect.

    Keep in mind that this "fragments" your user base. A client can only find games in the same region. Until there are many players, it might make sense to use less regions and hide the lag a bit better.
     
  3. sushil9394l

    sushil9394l

    Joined:
    Aug 2, 2020
    Posts:
    6
    I Cant Use PhotonNetwork.OverrideBestCloudServer(), it Says it Doesn exist?
     
  4. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    Cause this thread is from 2015 and the api changed since.
    Have a look at BestRegionSummaryInPreferences instead for PUN 2.
     
    Joe-Censored likes this.