Player stutter fix
This commit is contained in:
@@ -133,19 +133,20 @@ public class Client
|
||||
//1.12 == [1] = 1, [2] = 12
|
||||
public void SendPositionUpdate(Vector3 position)
|
||||
{
|
||||
string x = position.x.ToString("F");
|
||||
string y = position.y.ToString("F");
|
||||
string z = position.z.ToString("F");
|
||||
byte xV = byte.Parse(x.Split(',')[0]);
|
||||
byte xN = byte.Parse(x.Split(',')[1]);
|
||||
|
||||
byte yV = byte.Parse(y.Split(',')[0]);
|
||||
byte yN = byte.Parse(y.Split(',')[1]);
|
||||
|
||||
byte zV = byte.Parse(z.Split(',')[0]);
|
||||
byte zN = byte.Parse(z.Split(',')[1]);
|
||||
string x = position.x.ToString("n4");
|
||||
string y = position.y.ToString("n4");
|
||||
string z = position.z.ToString("n4");
|
||||
|
||||
Send(new byte[] { 7, xV, xN, yV, yN, zV, zN });
|
||||
string sendPosition = x + " " + y + " " + z;
|
||||
byte[] sendPositionASCII = Encoding.ASCII.GetBytes(sendPosition);
|
||||
byte[] send = new byte[sendPositionASCII.Length + 1];
|
||||
send[0] = 7;
|
||||
for (int i = 1; i < send.Length; i++)
|
||||
{
|
||||
send[i] = sendPositionASCII[i - 1];
|
||||
}
|
||||
|
||||
Send(send);
|
||||
}
|
||||
|
||||
private void Receive()
|
||||
@@ -171,16 +172,19 @@ public class Client
|
||||
|
||||
if (data[0] == 7)
|
||||
{
|
||||
string xS = data[1] + "," + data[2];
|
||||
string yS = data[3] + "," + data[4];
|
||||
string zS = data[5] + "," + data[6];
|
||||
byte[] positionASCII = new byte[data.Length - 2];
|
||||
for (int i = 0; i < data.Length - 2; i++)
|
||||
{
|
||||
positionASCII[i] = data[i + 2];
|
||||
}
|
||||
|
||||
float x = float.Parse(xS);
|
||||
float y = float.Parse(yS);
|
||||
float z = float.Parse(zS);
|
||||
|
||||
byte id = data[7];
|
||||
byte id = data[1];
|
||||
|
||||
string[] positionString = Encoding.ASCII.GetString(positionASCII).Split(' ');
|
||||
float x = float.Parse(positionString[0]);
|
||||
float y = float.Parse(positionString[1]);
|
||||
float z = float.Parse(positionString[2]);
|
||||
|
||||
world.UpdatePlayerPosition(new Vector3(x, y, z), id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user