Unity3D MMORPG 后端服务器

Backend server for Unity3D MMORPG

我正在使用 Unity 引擎开发一个基本的 MMORPG。 我需要一个简单的解决方案(库、框架)来制作高效的服务器。 完成此任务的最佳方法是什么?

原来的post是here

  1. 您可以尝试 SmartFox, this link 可能对您来说是一个好的开始。以下教程也有助于快速入门:

具体来说,您可以连接到 smartfox 服务器并在连接时收到通知:

private SmartFox client;
private string serverIP = "127.0.0.1";
private int serverPort = 9933;  
private string zone = "BasicExamples";

client = new SmartFox();           
client.ThreadSafeMode = false; //true for Unity3D
client.AddEventListener(SFSEvent.CONNECTION, (evt) =>
        {
            bool bSuccess = (bool)evt.Params[“success”];
            Console.WriteLine(client.IsConnected ?
                “Successfully connected to SmartFox Server” :
                “Failed to connect to SmartFox Server”);
        });           
client.Connect(serverIP, serverPort);            

要登录并在登录成功时挂钩:

var request = new LoginRequest("UserName", "Password", zone);  //[1]
client.Send(request);                                          //[2]

client.AddEventListener(SFSEvent.LOGIN, (evt) => {             //[3]
            Console.WriteLine("The User login success");       
});

client.Connect(serverIP, serverPort);   

2。 Photon 是另一个流行的后端 server/service.

Photon Server provides you with turnkey frameworks for multiplayer games. Start from scratch or build your own custom logic on top of several demo applications included in source code with the free server SDKs. This lets you achieve great results fast and easy.

设置连接的代码片段:

using UnityEngine;

public class RandomMatchmaker : MonoBehaviour
{
    void Start() {
        PhotonNetwork.ConnectUsingSettings("0.1");
    }

    void OnGUI(){
       GUILayout.Label(PhotonNetwork.connectionStateDetailed.ToString());
    }
} 

加入的代码片段 room/lobby:

public override void OnJoinedLobby()
{
    PhotonNetwork.JoinRandomRoom();
}

设置日志的代码片段:

PhotonNetwork.logLevel = PhotonLogLevel.Full;

错误处理代码片段:

void OnPhotonRandomJoinFailed()
{
    Debug.Log("Can't join random room!");
    PhotonNetwork.CreateRoom(null);
}

可以找到关于这个主题的很好的教程 here


3。 Firebase 可能是第三个选择,尽管性能可能还不清楚。

  • 例如,在 roll20.net 中,您可能会发现由 Firbase 提供支持的 MMO 游戏。
  • 除其他外,FireSharp 可能是一个非常有用的开源项目,可帮助您快速入门。

4.其他(OpenSpace、RedDwarf、ElectroServer、Player.IO、Red5、Mesmotronic 多用户服务器等)

See this great post for details.