Issues with movement of other players VIA a networked server.

Ok, well, some of the identifier information of the packet has been stripped but basically this is the issue.

Other Players move very slowly, generally at intervals that the Other Player packet is received by the client from the server. They also “skip” across the terrain.

I attempted to create a background / threaded process to handle these player movements, as I assumed that moving the process to a thread, and making the process repeat the controller.move() function until the player is at the position the last packet was received stated it should be.

Here’s the class to handle the movement of “other” players, as well as the spawn and destroy of them;

public class packetMovePlayer
{
	public void movePlayer(){
				string[] array = packet.packetHeader;
		string[] arrayContents = packet.packetDataArr;
		if(arrayContents.Length == 7){
				//Let's check to see if we have created a game object for this player!
					if(GameObject.Find(arrayContents[0]) != null){
						float theDistance = Vector3.Distance(GameObject.Find("player").transform.position, new Vector3(float.Parse (arrayContents[1]),float.Parse (arrayContents[2]),float.Parse (arrayContents[3])));
						Debug.Log(theDistance);
						if(theDistance <= 150){
						//Player already exists!!!
						GameObject player = GameObject.Find (arrayContents[0]);
						//CharacterController controller = player.GetComponent(typeof(CharacterController)) as CharacterController;
						Vector3 position = new Vector3(float.Parse (arrayContents[1]),float.Parse (arrayContents[2]),float.Parse (arrayContents[3]));
						Vector3 newPosition = position - player.transform.position;
						CharacterController controller = player.GetComponent(typeof(CharacterController)) as CharacterController;
							 //newPosition *= 6.0F;
						

						controller.Move(newPosition * Time.deltaTime);

						//player.transform.Rotate(rotation);
						}else{
						GameObject.Destroy (GameObject.Find (arrayContents[0]));	
						}

					}else{
						float theDistance = Vector3.Distance(GameObject.Find("player").transform.position, new Vector3(float.Parse (arrayContents[1]),float.Parse (arrayContents[2]),float.Parse (arrayContents[3])));
						Debug.Log(theDistance);
						if(theDistance <= 150){
						//Player GO doesn't exist! Let's create it now!
						//Vector3 rotation = new Vector3(float.Parse (arrayContents[4]),float.Parse (arrayContents[5]),float.Parse (arrayContents[6]));
						GameObject.Instantiate(GameObject.Find ("defaultPlayerMesh"));
						GameObject player = GameObject.Find ("defaultPlayerMesh(Clone)");
						player.name = arrayContents[0];
						CharacterController controller = player.GetComponent(typeof(CharacterController)) as CharacterController;
						Vector3 position = new Vector3(float.Parse (arrayContents[1]),float.Parse (arrayContents[2]),float.Parse (arrayContents[3]));
						//Vector3 targetDirection = Vector3.zero;
						//Vector3 rotation = Vector3.RotateTowards(position, targetDirection, 500.0 * Mathf.Deg2Rad * Time.deltaTime, 1000);
						Vector3 inAirVelocity = Vector3.zero;
						Vector3 movement = position * Convert.ToSingle(6.0) + new Vector3 (0, 20, 0) + inAirVelocity;
						//movement *= Time.deltaTime;
						//player.transform.Rotate(rotation);

						controller.Move(movement * Time.deltaTime);

						//controller.Move(movement);
						
						//player.AddComponent ("Rigidbody");
						//player.AddComponent ("Skinned Mesh Renderer");
						}
						
					}
		
	}}
}

Please note, the server is NOT written with Unity3D, it is written in C# for a lower footprint. The issue here is with the client script, not the server.

I have called this specific class function with the following code;

		packetMovePlayer thePlayer = new packetMovePlayer();
				thePlayer.movePlayer(); //Spawn movement thread. This should make the player movement a background process!

Any ideas?

Ok, SO!

It took a bit of work, the solution was to store All the updated player movement details from packets into a list, and to add the following code to my Update() statement;

		if(playerMovements.Count != 0){
		//player movements to do!	
			foreach(playerMover p in playerMovements){
									if(GameObject.Find(p.Name) != null){
						float theDistance = Vector3.Distance(GameObject.Find("femaleWarrior").transform.position, new Vector3(float.Parse (p.x),float.Parse (p.y),float.Parse (p.z)));
						Debug.Log(theDistance);
						if(theDistance <= 150){
						//Player already exists!!!
						GameObject player = GameObject.Find (p.Name);
						//CharacterController controller = player.GetComponent(typeof(CharacterController)) as CharacterController;
						Vector3 position = new Vector3(float.Parse (p.x),float.Parse (p.y),float.Parse (p.z));
						Vector3 newPosition = position - player.transform.position;
						CharacterController controller = player.GetComponent(typeof(CharacterController)) as CharacterController;
							 //newPosition *= 6.0F;
						
						controller.Move(newPosition * Time.deltaTime);
						if(player.transform.position == position){
						playerMovements.Remove (p);	//Remove the player as there are no more movements to make!
						}
						//player.transform.Rotate(rotation);
						}else{
						GameObject.Destroy (GameObject.Find (p.Name));
						}
			}
		}
		}
		//End player movements!