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

偶尔发现一个宝藏插件Mirror

 

由于最近在做一些多人同步的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.

  • 2
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

avi9111

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值