关于游戏网络延迟的资料

client-server

  1. the server takes snapshots of the current world state at a constant rate and broadcasts these snapshots to the clients.
  2. server -> snapshot  -> client
  3. server  <- userinput <- client
  4. server runs a physical simulation step, checks the game rules, and updates all object states
  5. the client has to tell the server its incoming bandwidth capacity
  6. server doesn't send a full world snapshot each time, but rather only changes, Usually full (non-delta) snapshots are only sent when a game starts or a client suffers from heavy packet loss for a couple of seconds

Input prediction

1.local client just predicts the results of its own user commands. 2.if server result != client, Then the client has to correct its own position, since the server has final authority over client-side prediction 3.Prediction is only possible for the local player and entities affected only by him

Lag compensation

1.The lag compensation system keeps a history of all recent player positions for one second. If a user command is executed, the server estimates at what time the command was created as follows:

Command Execution Time = Current Server Time - Packet Latency - Client View Interpolation

Then the server moves all other players - only players - back to where they were at the command execution time. The user command is executed and the hit is detected correctly. After the user command has been processed, the players revert to their original positions.

end

Network latencies and lag compensation can create paradoxes that seem illogical compared to the real world. For example, you can be hit by an attacker you can't even see anymore because you already took cover. What happened is that the server moved your player hitboxes back in time, where you were still exposed to your attacker. This inconsistency problem can't be solved in general because of the relatively slow packet speeds. In the real world, you don't notice this problem because light (the packets) travels so fast and you and everybody around you sees the same world as it is right now.

转载于:https://www.cnblogs.com/lightlfyan/p/4201109.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值