记一次Unity最新多人联网同步框架Mirror

偶尔发现一个宝藏插件Mirror

记一次Unity最新多人联网同步框架Mirror_第1张图片

 

由于最近在做一些多人同步的Demo

由于习惯性思维,先百度

能搜索到的,无非是什么unet 或者photon,

先不管要不要收费,或者收费如何

首先这些网上的一般项目,配置就是一个大问题

-Photon其实是好用的(不要问哥怎么知道的)只要你公司钱给够

配置难其实也就是收费的原罪,一是要验证,二是源码不公开

本来我也想用用Unet等

自己试了一遍后发现,service 没有, package manager没用,安装了 xxxx mlai也是安装了寂寞

所以:

直接安装 Mirror,还免费的
 

可能会碰到2个问题吧

1.是 Horizantal 按键没设置

只需要在Editor -> PlayerSettings , Input Manager设置上即可

2.BuildSettings缺subScene

(本身要放弃Mirror了,觉得和其他框架一样)哥也是在全局搜索tank才发现这个场景( .unity);

其实只要在File -》 BuildSettings设置上即可

以上都是基本设置了,有些Unity经验就都能搞定

搞定后居然发现,他喵的,Mirror居然是开源的

居然是开源的

居然是开源的!

也估计从旧版本Tank二次开发而来,但这不重要了

重点是:居然是开源的!

(需要研究代码)

不是一般的项目,或联网例子,这是多人平滑移动必须,懂得就懂了

(代码如下,是研究多人移动的宝藏项目啊)

  void UpdateClient()
        {
            // client authority, and local player (= allowed to move myself)?
            if (IsClientWithAuthority)
            {
                // send to server each 'sendInterval'
                // NetworkTime.localTime for double precision until Unity has it too
                //
                // IMPORTANT:
                // snapshot interpolation requires constant sending.
                // DO NOT only send if position changed. for example:
                // ---
                // * client sends first position at t=0
                // * ... 10s later ...
                // * client moves again, sends second position at t=10
                // ---
                // * server gets first position at t=0
                // * server gets second position at t=10
                // * server moves from first to second within a time of 10s
                //   => would be a super slow move, instead of a wait & move.

你可能感兴趣的:(每天一点u3d,互联网,unity,游戏引擎)