Quantcast
Channel: Photon Unity Networking (PUN) — Photon Engine
Viewing all articles
Browse latest Browse all 8947

Changing regions manually

$
0
0
Hi there,
I'm currently connecting to the Photon Cloud using "Best Region" for the Hosting field inside the PhotonServerSettings and it's working great! I would like however to let my players change themselves the region they connect to from within the game. This could be really useful if a player from East Coast USA would like to play with a friend from the West Coast for example. I'm having some trouble writing the correct syntax for the function that changes the region they're connected to. Here's what I'm using:

PhotonHandler.BestRegionCodeInPreferences = CloudRegionCode.usw;
PhotonNetwork.Disconnect();

PhotonNetwork.ConnectUsingSettings(GameVersion);
// OR
PhotonNetwork.networkingPeer.ConnectToRegionMaster(CloudRegionCode.usw);


I check to see what my connection status is by printing it to a text field
Status.text = PhotonNetwork.connectionStateDetailed.ToString();

When I first connect using "Best Region" it says "ConnectedToMaster" and it allows me to join or create a room in which I can play with other game clients. With the code I wrote above however all I'm getting is "ConnectedToNameServer". How do I get to the master from there? Neither ConnectUsingSettings() nor ConnectToRegionMaster() doesn't seem to do the trick. If I restarted the game, it does connect properly to the new region due to changing the BestRegionCodeInPreferences but it's not a very elegant solution.

I found this article here https://doc.photonengine.com/en-us/realtime/current/getting-started/realtime-intro which talks about "using ExitGames.Client.Photon.LoadBalancing;" but when I try to use that, I'm getting that the namespace doesn't exist and I have a feeling that's probably not what I should be using for my Cloud Hosting.

Thanks in advance!

Viewing all articles
Browse latest Browse all 8947

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>