關於dota2同步方式


http://dev.dota2.com/showthread.php?t=527&page=7&p=4253&viewfull=1#post4253

 

Again, I don't recommend using that script. Let me explain how the networking model works in Dota 2 and where this "unit delay" people are describing is coming from.

The Source engine is an UDP based networking system that sends snapshot of the unit state to the client at regular intervals. This is the cl_updaterate and its currently locked at 20Hz on our servers right now. This means that every 50ms, the game transmits the position of all the units in the game, their states, etc. (For the curious, I worked with John Carmack when this model was developed in Quakeworld at id Software).

The way your client handles this is it interpolates between these snapshots. By default, the cl_interp_ratio is 2, which means it interpolates it between three snapshots. Let me explain with a timeline. This assumes you have zero ping (or very low ping):

Code:
Time       Server       Client
0.00       Snapshot A   Idle
0.05       Snapshot B   Gives command for the hero to move
0.10       Snapshot C   Idle
0.15       Snapshot D   Idle

In this case, you first get Snapshot A and the client doesn't do anything as it has no succeeding snapshot. Snapshot B comes in and the client starts interpolating the motion between A and B. At this point the client tells his hero to start moving. The server responds immediately to this command and starts moving the hero on the server. Snapshot C comes in, but the client is still interpolating between A to C since cl_interp is 0.1, or 10Hz. D eventually comes in and now you start seeing the unit fully respond to your movement command as now you are interpolating between B and D. We interpolate at 10Hz instead of 20Hz so if you lose a packet from the server or its delayed a few microseconds, we "smooth" over it by interpolating around the missed packet.

There isn't an artificial unit delay, its due to the interpolating between snapshots (which gives smooth motion on the client) that causes it to feel a bit delayed. Since the interpolation time is 10Hz (100ms), it can take roughly half that time, 50ms, before a unit starts to move or appear to respond to its latest command.

Now this model was tuned for games that have prediction such as Counterstrike, Left 4 Dead, Team Fortress 2, etc. Dota 2 doesn't have prediction as you're basically giving orders to units on battlefield. You're not directly controlling the player as you would in those games and there isn't hitscan based weapons that need prediction and lag compenstation in order to aim. You don't aim in Dota 2, you give commands.

With this, I'm exploring increasing the snapshot frequency to lower the interpolation time to 50ms. This will cause the perceived respond time to lower to around a 25ms average.

Of course, you need to add your ping time to all of this. If your ping is 135ms, then its going to take that much longer for the unit to respond. I'm not sure why the ping is so high from France to our new data center in Luxembourg. We recently relocated our servers there and we're still tweaking and talking to ISPs around there. I'll talk to our network administrators about it, but emailing me a traceroute would be great.

 

 

dota2這篇論壇上的資料透露, Counterstrike, Left 4 Dead, Team Fortress 2等游戲都采用了該技術,而dota2在此技術的基礎上,去掉了客戶端預測,減少了拉扯現象,不過玩家的控制信息得不到立即反饋,該文章也是為了解答玩家關於控制延遲的疑問。

總體的意思是DOTA2使用udp,快照同步的方式,我從觀看錄像來分析,下載的文件有50M大小,不可能只存儲了輸入事件,肯定存了快照,而且錄像可以快進倒退,拖動,切換陰影,確實牛逼


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM