How to let my player to connect to a region manually

Options
First of all i know this questions has bee asked a lot of times before but none of them helped me ... I just started using PUN because now i m planning a multiplayer game so i started reading the documentation and i got to know about regions and this thing got me excited as i want a feature in my game that shows a list of available regions along with their ping so that my user can select from them and connect to that region ... in other answers they are saying to use something like opGetRegions (or something like this) but i don't know how to use it ... basically i want a Dota like feature where you connects to a a region that is selected by you and not by system based on Best-Ping

Answers

  • Wyvern_IX
    Options
    Here's a list of regions you can connect to: https://doc.photonengine.com/en-us/pun/current/reference/regions. Notice the token's for each region, those are what you use to connect, as seen in the example below.

    I imagine you'll have a selector of sorts that allows players to choose between the different available regions. Here's how you connect to South America:

    PhotonNetwork.ConnectToRegion(CloudRegionCode.sa,yourGameVersionInteger);

    Here's how you connect to Asia:

    PhotonNetwork.ConnectToRegion(CloudRegionCode.asia,yourGameVersionInteger);

    I'm not sure if the following step is needed, but I had to change my PhotonServerSettings Hosting value to "Best Region" and the "Enabled Regions" value set to "Everything" to get it working how I wanted.
  • Aditya
    Options
    Wyvern_IX said:

    Here's a list of regions you can connect to: https://doc.photonengine.com/en-us/pun/current/reference/regions. Notice the token's for each region, those are what you use to connect, as seen in the example below.

    I imagine you'll have a selector of sorts that allows players to choose between the different available regions. Here's how you connect to South America:

    PhotonNetwork.ConnectToRegion(CloudRegionCode.sa,yourGameVersionInteger);

    Here's how you connect to Asia:

    PhotonNetwork.ConnectToRegion(CloudRegionCode.asia,yourGameVersionInteger);

    I'm not sure if the following step is needed, but I had to change my PhotonServerSettings Hosting value to "Best Region" and the "Enabled Regions" value set to "Everything" to get it working how I wanted.

    I've not tested your suggestion yet but what i think if i will enable "Best Region" in PhotonServerSettings that it will compare pings with other regions and will connect my user to the region with "BEST PING" no matter whatever i chose in PhotonNetwork.ConnectToRegion ... But right now i m not with my PC, but as soon as i'll reachout to my PC, i will test this out and will get back to you with result ... Hoping For Best
  • Wyvern_IX
    Options
    From my knowledge, you'd only compare pings and choose the best ping with the "Best Region" setting enabled if you use PhotonNetwork.ConnectUsingSettings to connect as seen in the documentation here: http://doc-api.exitgames.com/en/pun/current/class_photon_network.html#a0fdb79bcce45801ec81fbe56ffb939ec

    Using ConnectToRegion will bypass your PhotonServerSettings and connect to whatever region you specify. Stated here: http://doc-api.exitgames.com/en/pun/current/class_photon_network.html#a84b7be74d130b19eeeb1d7b4e8193ad4
  • Aditya
    Options
    Fhew ... Now that gave me a ray of hope ... Okay so now i know that i can connect to any region of my choice, and as i m doing this manually, what to do after it, i mean do i have to connect to a Master server too or can i just make my normal calls like creating rooms, joining them and other normal networking stuff
  • Wyvern_IX
    Options
    Connecting in this way already connects you to a master server. Now that the player is connected, you can use the normal calls to your liking.
  • Wyvern_IX said:

    Here's a list of regions you can connect to: https://doc.photonengine.com/en-us/pun/current/reference/regions. Notice the token's for each region, those are what you use to connect, as seen in the example below.

    I imagine you'll have a selector of sorts that allows players to choose between the different available regions. Here's how you connect to South America:

    PhotonNetwork.ConnectToRegion(CloudRegionCode.sa,yourGameVersionInteger);

    Here's how you connect to Asia:

    PhotonNetwork.ConnectToRegion(CloudRegionCode.asia,yourGameVersionInteger);

    I'm not sure if the following step is needed, but I had to change my PhotonServerSettings Hosting value to "Best Region" and the "Enabled Regions" value set to "Everything" to get it working how I wanted.

    Just what i needed, for some reason i was always having 350-400ms on my game, and now that i manually connect to southamerica i get 105... Thanks!