There have been some professional solutions suggested; but just to clarify why I asked about TCP usage for movement; UDP - being the fastest solution of the two which is also used in most AAA games I have played, sending positions a number of times per second would compensate for lost packets; and is doing so on millions of game sessions across hundreds of countries on X-Boxes, PS3s and PCs as I type this message. Again, TCP has professional applications in video games, such as Michael mentioned.
To my point regarding interpolation, because Sph!nx wasn't very sure.
Let us exaggerate for a moment and imagine that the new position of each player is synchronized once every 2 seconds; which in a real world live game would be catastrophic.
Let us think of vectors as XYZ positions.
In the following example, a new position is given to a set of cones once every 2 seconds; I have used linear interpolation on a blue cone, curved on a green cone, and no interpolation on the red cone. If you can grasp the sense of linear interpolation; then Catmull-Rom is something that can help you guess the path of motion, not just in a straight line.
This will show you how interpolation helps reduce lag; although there is no cure for poor network performance; at least it looks like the players are walking forward every two seconds, instead of teleporting! In a real game your movement would be updater numerous times per second.
` Chris Tate - Movement Interpolation
` Create cones
Make Object Cone 1, 1 : Color Object 1, 0xFF0000 : XRotate Object 1, 90 : Fix Object Pivot 1
Make Object Cone 2, 1 : Color Object 2, 0x00FF00 : XRotate Object 2, 90 : Fix Object Pivot 2
Make Object Cone 3, 1 : Color Object 3, 0x0000FF : XRotate Object 3, 90 : Fix Object Pivot 3
CurveSharpness# = 10.0
LinearSpeed# = 0.05
Dim Path(6)
Dim Pos(3)
null = Make Vector3(1)
null = Make Vector3(2)
null = Make Vector3(3)
null = Make Vector3(4) : Path(1) = 4
null = Make Vector3(5) : Path(2) = 5
null = Make Vector3(6) : Path(3) = 6
null = Make Vector3(7) : Path(4) = 7
null = Make Vector3(8) : Path(5) = 8
null = Make Vector3(9) : Path(6) = 9
` Position the cones and points
` If you have matrix 1 utilities use: Position Object At Vector
` Set out path
For i = 1 to 9
Set Vector3 i, RND(10)-8, 0, RND(10)-8
If i => 4
Make Object Sphere i, 0.5, 4, 4
Color Object i, RGB( i * 25, i * 25, i * 25)
Position Object i, X Vector3( i ), Y Vector3( i ), Z Vector3( i )
EndIf
Next i
Position Object 1, X Vector3( 4 ), Y Vector3( 4 ), Z Vector3( 4 ) : Pos(1) = 2
Position Object 2, X Vector3( 6 ), Y Vector3( 6 ), Z Vector3( 6 ) : Pos(2) = 4
Position Object 3, X Vector3( 8 ), Y Vector3( 8 ), Z Vector3( 8 ) : Pos(3) = 6
RepositionDue = 0
Sync Rate 20
` Setup the camera
Position Camera 0,15,0
Point Camera 0,0,0
Color Backdrop 0x000000
Do
Set Cursor 0, 0
For i = 4 to 9
Center Text Object Screen X(i), Object Screen Y(i) + 30, Str$(i)
Next i
For o = 1 to 3
Print "Player[" + Str$(o) + "] position index: " ; Path( Pos(o) )
` Change points
If RepositionDue <= Timer()
Inc Pos(o)
If Pos(o) > Array Count( Path() ) Then Pos(o) = 1
Step# = 0.0` Set the linear step to zero
Point Object o, X Vector3( Path( Pos(o) ) ), Y Vector3( Path( Pos(o) ) ), Z Vector3( Path( Pos(o) ) )
Endif
` Look at next point
` Move
Select o
` Red - No interpolation
Case 1
Position Object o, X Vector3( Path( Pos(o) ) ), 0.0, Z Vector3( Path( Pos(o) ) )
Endcase
` Green - Curved position
Case 2
x# = CurveValue( X Vector3( Path( Pos(o) )), X Vector3( o ), CurveSharpness# )
z# = CurveValue( Z Vector3( Path( Pos(o) )), Z Vector3( o ), CurveSharpness# )
Set Vector3 o, x#, 0.0, z#
Position Object o, X Vector3( o ), 0.0, Z Vector3( o )
Endcase
` Blue - Linear interpolation position
Case 3
If Step# > 1.0 Then Step# = 1.0
Linear Interpolate Vector3 o, o, Path( Pos(o) ), Step#
Step# = Step# + LinearSpeed#
Position Object o, X Vector3( o ), 0.0 , Z Vector3( o )
Endcase
Endselect
Next o
` Reset timer if needed
If RepositionDue <= Timer()
RepositionDue = Timer() + 2000 ` This should be done more accurately in a real game; unless the given matter is trivial
Endif
Loop
But that is just a starting point; in a serious application of this technique; you would also transmit the angle and speed of the moving players. Using the last 2 positions, a Catmull-Rom curve would help your video game guess where the player will be in the next second or two.
Do not put too much emphasis on optimization and interpolation until you get the game working; first get it working, then refine it; you might end up optimizing and interpolating something that does not and cannot work