4. Regions, Scaling and Analytics
Choosing a region
Script 4.1
await McHosting.ConnectAsync(ServerRegions.Any, playerId); // MultiConnectCloud chooses
await McHosting.ConnectAsync(ServerRegions.Europe, strictRegion: true, playerId); // that region or fail
var best = await McHosting.ConnectToBestRegionAsync(playerId); // lowest ping
var regions = await McHosting.MeasureRegionsAsync(); // for a region menu, fastest first
Scaling
Plans, regions, autoscaling, grace periods and environment variables are set on the deployment's page on the dashboard, and every deploy keeps them. With a master, game servers can also start one per match, so you pay only while a match runs.
Inside a server on MultiConnectCloud, McHostingEnvironment tells you where you are running: IsHosted, Role, Region, PublicHost, DeploymentId and more. For example, one build can serve as a local combined server and a hosted game server:
Script 4.2
var gameServer = MultiConnectGameServer.instance;
gameServer.UseAsMasterServer = McHostingEnvironment.Role != McHostedRole.WorkerServer;
Analytics
With an SDK key in place, the Game Analytics page on the dashboard shows players, matchmaking, servers and your own events, with nothing else to set up. Add custom events on clients or servers:
Script 4.3
McAnalytics.Track("level_complete", new Dictionary<string, string>
{
["level"] = "3",
["result"] = "win",
});
Names may use letters, digits and _ . : -, up to 64 characters, with up to 10 string properties. Keep ids out of names: level_complete with a level property, not level_3_complete.
Runs in the Editor or against a local server send nothing. To test analytics locally, set McAnalytics.SendFromLocalRuns = true before initialising.

