GithubHelp home page GithubHelp logo

netcodedemo's Introduction

ET_NetcodeDemo

Demo for netcode,develop with ET

设计思路

1.模仿守望先锋分享的流程(同步方式是命令帧+状态),但是以MOBA来做先. (后面俯视角的做完了,再开个分支做第三人称过肩视角的TPS)

2.客户端16ms帧间隔,服务器48ms. 这样服务器一秒差不多20帧,客户端一秒60帧.(守望是服务器也16ms,但是每3帧同步1次.这里moba没必要那么严格)

客户端存在3个时间点:

  • 2.1 最后收到的服务器时间点. 也就是服务器更新每帧消息时,转换为的客户端帧数
  • 2.2 当前为整个世界内非主角单位插值用的模拟时间点. 一般会比服务器时间点慢6帧(也就是服务器上的2帧)
  • 2.3 主角单位自身模拟的时间点. 一般为最后确认的时间点+RTT+3 (这个3代表服务器上的1帧)

3.客户端每帧流程->

  • 3.1 先更新服务器下发的各种世界状态变化 (主角自己的不做处理,走预测模拟那套)
  • 3.2 检测是否可以继续模拟(客户端模拟时间相对已经确定的帧,不会超过250ms)
  • 3.3 如果可以继续模拟下一帧,就模拟帧+1检测自己的输入,发送输入给服务器(如果有的话)

4.服务器每帧流程->

  • 4.1 帧步进,先收集各个输入,对世界状态进行一定的修改.
  • 4.2 驱动世界刷新
  • 4.3 遍历所有单位状态,计算每个玩家需要更新的帧数据增量.
  • 4.4 遍历所有玩家,下发对应的帧数据增量

TODO

1.目前前后端寻路方案不一致,导致没法做服务器验证客户端寻路路径.所以暂时完全相信.以后客户端也改成recast寻路再说.
2.需要支持单位移动速度突变
3.加入战斗元素,做一下简单的PVP. (有造成伤害,死亡,复活流程)

演示视频(延迟10~750ms)

ET.mp4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.