Smooth Movement with RPC's

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;
	}

First off. Don’t use RPCs for position updates–that’s an inappropriate use and it will lead to you pain. You ought to look up some of the unity networking tutorials to learn the proper way to do this. Try looking here: http://docs.unity3d.com/Manual/net-StateSynchronization.html
and here Unity - Scripting API: Network.OnSerializeNetworkView(BitStream,NetworkMessageInfo)

Now, to answer your question:

What you want to do in interpolate between the positions provided by the net code. Look up Vector3.Lerp.

Basically, when you get a position update, you begin lerping the position of the thing towards the new position. Then, when you get the next nework update with position, you update the current position to the LAST position received and being lerping the position towards the NEW position. The time you want it do do this movement in is approximately the time it takes between newrok updates.