Hey,
I’m working on a University project in which processing is distributed via RPC’s. I have a server and two clients and have gotten to a stage in which the clients see two boxes and have two buttons on their screen. Each button will move a box, however the physics for box one occurs on the server and the position is then sent to the clients and with box two the physics is carried out on client one with the results of the button press being sent out to other clients. Below is the code I have, however on the machines in which the physics processing isn’t taking place the box movement is very twitchy and not smooth. It’s almost as though it teleports to the position. I realise I am just sending the position of the box causing it to look jittery but i don’t know of any other way. How can i smooth out the movement of the boxes on the machines that don’t do the processing?
if(GUILayout.Button("Move Box One"))
{
networkView.RPC("SendCubeOneMoved", RPCMode.Server, null);
}
if(GUILayout.Button("Move Box Two"))
{
if (localPlayer == target)
{
cube2.rigidbody.AddForce(new Vector3(0,500,0));
cube2Pos = cube2.transform.position;
networkView.RPC("SendCubeTwoPosition", RPCMode.Others, cube2Pos);
}
}
break;
}
}
[RPC]
void SendCubeOneMoved()
{
cube1.rigidbody.AddForce(new Vector3(500,0,0));
cube1Pos = cube1.transform.position;
networkView.RPC("SendCubeOnePosition", RPCMode.Others, cube1Pos);
}
[RPC]
void SendCubeOnePosition(Vector3 cube1Pos)
{
cube1.transform.position = cube1Pos;
}
[RPC]
void SendCubeTwoPosition(Vector3 cube2Pos)
{
cube2.transform.position = cube2Pos;
}