Unity NGO

Explore how to host Unity projects on Edgegap using techniques from the NGO Boss Room Sample.

This sample does not require any Unity Gaming Services (UGS), Multiplay, or Relays to run.

βœ”οΈ Preparation

Before we start, you will need:

⚑ Deploy and Connect

1. Deploy a Server on Edgegap

β˜‘οΈ To get started, you'll need to create a free account with Edgegap. No credit card required.

β˜‘οΈ Create a new app version for your application, choose NGO Boss Room Sample.

β˜‘οΈ Deploy a server with your NGO Boss Room Sample app version.

β˜‘οΈ Open your new deployment's details and find your unique, one-time connection details:

  • External Port in format 30854 (5 digits).

β˜‘οΈ Navigate to tab Logs and find (CTRL+F) your unique, one-time connection details:

  • ARBITRIUM_PUBLIC_IP in format 172.234.244.38 .

βœ… You may now proceed to the next step.

2. Connect from Editor

β˜‘οΈ Open your new project in Unity.

β˜‘οΈ Press the ▢️ Play button to start your game client:

  • press START WITH DIRECT IP button,

  • select tab JOIN WITH IP.

β˜‘οΈ Input connection details from previous step.

β˜‘οΈ Press JOIN button to connect to your server.

β˜‘οΈ Connect a second virtual Player with Multiplayer Play Mode or ParrelSync.

πŸ™Œ Congratulations on your first Deployment on Edgegap!

✏️ Customize Server Build

Run as Dedicated Server

For this sample to run as dedicated server, we made the following changes:

New script (added to your MainMenu scene in a new empty GameObject):

Assets/Scripts/EdgegapServerStarter.cs
using System;
using System.Collections;
using System.Collections.Generic;
using Unity.BossRoom.ConnectionManagement;
using UnityEngine;

namespace Unity.Multiplayer.Samples.BossRoom
{
    public class EdgegapServerStarter : MonoBehaviour
    {
        public string portMapName = ;

        // Start is called before the first frame update
        void Start()
        {
            if (Application.isBatchMode)
            {
                ConnectionManager connectionManager = GameObject.Find("ConnectionManager").GetComponent<ConnectionManager>();
                string internalPortAsStr = Environment.GetEnvironmentVariable($"ARBITRIUM_PORT_{portMapName.ToUpper()}_INTERNAL");

                if (internalPortAsStr == null || !ushort.TryParse(internalPortAsStr, out ushort port))
                {
                    throw new Exception($"Could not find port mapping, make sure your app version port name matches with \"{portMapName}\"");
                }

                connectionManager.StartHostIp("", "0.0.0.0", port);
            }
        }
    }
}

Last updated

Was this helpful?