Unity UNet MMO风格的专用服务器方法

时间:2017-04-13 17:12:16

标签: networking unity3d dedicated-server unity3d-unet mmo

我们正在为我们的机构创建一个MMO风格的虚拟校园,我需要一些关于使用UNet的最佳实践和实施方面的建议。我在阅读之后得出的结论是,我应该使用一个带有单独场景的项目来构建服务器。所以我设置了它,它立即运行并启动一个专用服务器。然后游戏场景自动连接,但即使在网络管理器中添加了播放器,播放器也不会被实例化。服务器场景只是一个带有UNet网络管理器组件的空白场景。

我对这种情况的看法是,为了获得更好的用户体验,游戏场景和所有用户交互应该在客户端进行,然后更新服务器,然后服务器更新其他客户端。 (随意拍下来)。

如果以上是在正确的路径上,那么如何将服务器场景设置为重影而不实际处理任何信息?

编写一个将某些变量发送到服务器而不是使用UNet网络组件的脚本是否有益,因为我认为它们会同步整个对象?

UNet是否允许服务器只是作为中介更新客户端而不是游戏的完整实例的那种功能?

我认为我真正想到的是,使用UNet创建MMO风格,专用,无头,网络设置的最佳方法是什么?

1 个答案:

答案 0 :(得分:0)

I wouldn't use UNET's HLAPI (High-Level API) for an MMO. It gives you nice out of the box components like Network Transform and Network Manager, but you will not find the flexibility you need for a project of your scope. It may be possible, but the whole HLAPI feels like it was built to support a "host" hybrid which is both the server and a client (everyone being limited to the one Scene the host is running).

Check out the Low-Level API (LLAPI). It's just a thin, Unity-optimized layer on top of UDP sockets. It is a simple framework to send messages from Client --> Server, so it's entirely up to you to build the engine that moves players, manages scene changes, etc. This way, though, your server can be running on an entirely different Unity app with the sole purpose of processing client messages.