开发者

Synchronizing game sprites over network in XNA

开发者 https://www.devze.com 2023-02-28 15:57 出处:网络
I\'m making a two player 3D game, and need to synchronize the location of the remote player. Only one object, the avatar representing the player, needs to be synchronized between the two games.

I'm making a two player 3D game, and need to synchronize the location of the remote player. Only one object, the avatar representing the player, needs to be synchronized between the two games.

I thought this would be pretty straight forward, but it turns out even in a local network the remote player is moving in a stuttery way when playing on two different machines (two instances of the game on the same machine looks fine).

In the current approach one game is the server, while the other acts as a client, sending coordinates as text strings over a dedicated port. They are basically streaming avatar coordinates to each others, each time the avatar is actually moving.

Any idea how resolve lag related issues when sending/receiving coordinate开发者_C百科s? Only needs to work over a local network.


Glenn "Gaffer" Fiedler's series of articles on Networking for Game Programmers are pretty much the go-to guide for basic game network programming. He also has an article on Networked Physics.

Many of the techniques described in that series of articles (eg: reliability) are already implemented for you in libraries like Lidgren.

Basically the techniques you want to use are interpolation, extrapolation and prediction. There's a good explanation of them in this article in the aforementioned series, plus the Networked Physics one. Basically you take the unreliable, laggy stream of position data, and use that to make a visually plausible estimate of the actual path of the object.

0

精彩评论

暂无评论...
验证码 换一张
取 消