当前位置:网站首页>State synchronization and frame synchronization
State synchronization and frame synchronization
2022-04-23 07:44:00 【0zien0】
Sync , In fact, let all clients see the same content , for instance : Glory of Kings ,5V5 when , When a player A Released a skill ,10 Players ( Include A) You should be able to see players synchronously on your mobile screen A Released skills . So let's say , It generally refers to online games , Players see the same thing on their respective devices . And stand-alone games , Play your own , Basically no synchronization is required . The mainstream synchronization methods are generally state synchronization and frame synchronization .
One . Realization principle :
State synchronization :
The client sends operation instructions to the server , After receiving the instruction, the server performs logical processing , Return the final processing result to the client . Then the client returns the result according to the server , Just play the corresponding effect locally .
Such as :A Click the skill button ( Release a skill attack B), Then the client will send the message of using skills to the server , The server will process this message , Is it enough ” blue “ Put skills , Skills are right for B How much damage is done ,B Death or not , And so on , The results will eventually be returned to all players , Then on all players' devices ( client ) Will play skill release effects ,B Hit animation , then B The effect of deducting blood floating words and so on .
Frame synchronization :
The client sends instructions to the server , The server does nothing to forward instructions to all clients , Then, after all clients receive the instruction, they will execute logical processing locally , Then play the effect .
Two . Comparison of advantages and disadvantages :
1. Server pressure
State synchronization : Because the logical operation is on the server , Relatively speaking, the pressure will be relatively high .
Frame synchronization : No server pressure .
2. Logical consistency
State synchronization : Unified computing on the server , Absolutely consistent .
Frame synchronization : It takes a lot of effort to ensure consistency . Such as : Accept the random factor sent by the server at the beginning of the battle , To ensure that the random results of all clients are consistent . Try to avoid decimal point operation , To ensure that the calculation results on different devices will have errors, etc .
3. Break line reconnection :
State synchronization : It's easier to achieve , Because when reconnecting , The real-time data of the current round is on the server , The server only needs to send the data of the current server to the client , You can directly present the current combat interface state .
Frame synchronization : Because the server only has all the operation steps of the client , When reconnecting , You may need to start with the first step , Until this step of the current game progress , To restore the state of the whole combat interface .
4. Battle replay :
State synchronization : You need to record and save all the status information sent to the client , The quantity saved is relatively large .
Frame synchronization : Just save the operation records forwarded to the client , Playback implementation is more convenient .
5. Data volume :
State synchronization : More , Because the server needs to process all player States after logic , The processing results are sent to the client .
Frame synchronization : less , Just forward the operation instructions .
6. Network delay :
State synchronization : It can be pre expressed , Make players look relatively less stuck , Flow a little .
Frame synchronization : The whole game will be stuck , Poor effect .
7. anti-cheating :
State synchronization : It's simpler , Because the core computing logic is on the server , Even if the player modifies the client , Can only change his local display effect .
Frame synchronization : More difficult , Because the logical processing is performed locally on the client . However, the results can also be verified by some means , Such as : Verify the consistency of the results of all players , If a player cheats , Raised his attack , Then the player's client will show that a knife killed the other party , Other clients show that the other party is only normal blood deduction and does not die , This can also verify that the player's client exception . But there are also some cheating behaviors that are difficult to effectively stop , Such as : Show full map , All player positions, etc
8. Development efficiency :
State synchronization : The client server needs to be clear about the requirements , Co produce , Joint commissioning, etc ( There is more communication cost ). But because many games have battles PVE part , So in fact, there can be a client to uniformly develop the combat system , Single combat and networked combat use the same set of combat codes , This can save communication costs , However, you also need to add some special processing code related to the client or server .
Frame synchronization : The server is only responsible for forwarding , All code has client-side development ( No communication costs ), But also pay attention to ” Anti crack “,” Uniqueness of code execution results “,” Separation of logic and expression “ And so on .
9. Applicable scenario
State synchronization : Applicable to almost all games .
Frame synchronization : Not applicable to games with too many players ( High bandwidth ); Not suitable for large maps MMO game , Because in the game of super map , The client only has the data of this part of the area displayed by the current mobile phone , Other data of the map exists in the server , The client does not have all the data and cannot do logical processing .
PS: Most games can use two synchronization methods , Which is more suitable for , We need to consider the type of game 、 Combat mode 、 network bandwidth 、 Delay response 、 anti-cheating 、 Development cycle and other factors to choose different schemes , Even a mixture of the two , There is no best technology , Only the most appropriate technology . So which way to use can only depend on the specific needs of the project .
-------------------------------------------- Little knowledge -------------------------------------------
1. Early frame synchronization , The server will wait to receive all players' keyframe messages , Will be forwarded to all players , Cause a player to get stuck , All players are stuck , A terrible game experience when they all stop . Now the frame synchronization adopts ” Optimistic frame “, The server forwards the received message sent by the client to other clients at a fixed time interval , The one who doesn't wait for the card . In this way, only the player with the card will be stuck , Other normal network players play games normally , The experience is much better .
版权声明
本文为[0zien0]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230623293227.html
边栏推荐
猜你喜欢
ABAP 7.4 SQL Window Expression
SAP DEBUG调试FOR IN、REDUCE等复杂的语句
AuthorizationServer(授权服务器的简单搭建)
简易随机点名抽奖(js下编写)
Authorization+Token+JWT
SAP TRANSLATE使用数据对象掩码示例
页面动态显示时间(升级版)
How to judge whether a point is within a polygon (including complex polygons or a large number of polygons)
Implementation of MySQL persistence
‘npm‘不是内部或外部命令,也不是可运行的程序 或批处理文件
随机推荐
(扩展)BSGS与高次同余方程
自定义时间格式(YYYY-MM-DD HH:mm:ss 星期X)
SAP RFC_CVI_EI_INBOUND_MAIN BP主数据创建示例(仅演示客户)
MySQL isolation level
【自我激励系列】你永远不会准备好
Game assisted script development journey
二叉树的深度
手游性能优化
2022.3.14 Ali written examination
8. Paging query
4. Multi table query
11.表和库的管理
js之什么是事件?事件三要素以及操作元素
异步的学习
ogldev-读书笔记
ABAP CDS VIEW WITH ASSOCIATION示例
Nacos / sentinel gateway current limiting and grouping (code)
[牛客挑战赛47]C.条件 (bitset加速floyd)
14. Transaction processing
ABAP 7.4 SQL Window Expression