在 XNA 中通过网络同步游戏精灵 [英] Synchronizing game sprites over network in XNA

查看:49
本文介绍了在 XNA 中通过网络同步游戏精灵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个两人 3D 游戏,需要同步远程玩家的位置.两个游戏之间只需要同步一个对象,即代表玩家的头像.

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 coordinates? Only needs to work over a local network.

推荐答案

Glenn "Gaffer" Fiedler 关于 游戏程序员网络 几乎是基本游戏网络编程的首选指南.他还有一篇关于网络物理的文章.

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.

这篇关于在 XNA 中通过网络同步游戏精灵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆