Java – how to synchronize play services real-time multiplayer games

I'm using libgdx to develop an online version of the popular game pong I've started using Google's real-time multiplayer game service to send game data between players, but I can't figure out how to solve the synchronization problem I'm facing

The message currently sent is the player's paddle, so when I move, I send my new position to the opponent When the opponent receives, the time has passed and the synchronization is lost

I know there should be some waiting time between sports and use the slowest connection, but how to make it look smooth?

Solution

There is no clear answer to this question, but there are various strategies that people can adapt to this situation

Using UDP protocol (if you are using socket based communication, I will recommend you, because every MS is important in real-time games. I think Google API has UDP, which is unreliable messaging. Again, I have no experience in Google realtime API). Message exchange, interpolation, estimation, client prediction, etc. are only few

This is a very broad topic When I did my multiplayer tank game, I did something to make things look smoother

>Send actions to the server using UDP protocol. > I will keep two entries for players on the client One is the current value and the other is the value to be set Then I will multiply the current value with a smoothing factor of 0.3f until it is not equal to the value to be set (this helps reduce jitter) > I send important messages over TCP

The points I mentioned describe what I do in my game, but can be used for any one Although I suggest that you read the article on this website, which is called buffer on games

Again, this field is huge and there are no answers to help you I have done a paper on this topic, but I still can't give you a clear answer You will have to read many articles and simulate what you learn according to your needs

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>