I'm using XNA Lidgren for my project. But I'm having problems in the Player Movement. I always send them to the server in the Update Position Player Player, Position on Server to receive and pay for the other player to normal. But when the client receives Position shall be Lag. Through Debug, I discovered the problem lies in the "while ((incmsg = Client.ReadMessage ())! = Null)". While I think the reason it works faster gametime Quick Update and Draw Position will not keep the XNA New Position.
while ((incmsg = Client.ReadMessage()) != null)
{
switch (incmsg.MessageType)
{
case NetIncomingMessageType.Data:
{
string headStringMessage = incmsg.ReadString();
switch (headStringMessage)
{
case "CharacterMove":
{
string name = incmsg.ReadString();
int x = incmsg.ReadInt32();
int y = incmsg.ReadInt32();
foreach (OthersPlayer player in OthersPlayer.players)
{
if (player.name.Equals(name))
{
player.position = new Vector2(x, y);
}
}
}
break;