- Home /
 
I don't know difference between interpolation and non-interpolation
Hello, This is 00:24AM now.
First of all, I'm foreigner so my english skill is bad. Please understand my situation.
actually i have had some problem in Networking.
and Yesterday, i asked about this. but no one answered me. It's sad for me.
anyway.
void Update(){
     if (Network.isServer) {
         if (MoveDone) {
             if (Turn == 0) {
                 MoveSmooth (playerList1 [0], destinationTile);
 
               void MoveSmooth(Player player,Vector3 destination){
     if (Vector3.Distance (player.transform.position, destination) > 0.3) {
         player.transform.position += (destination - player.transform.position).normalized*5*Time.deltaTime;
         
         if(Vector3.Distance (player.transform.position, destination) <= 0.3){
             player.transform.position = destination;
             MoveDone = false;
             Turn++;
             if(Turn == 2)
                 Turn = 0;
         }
     }
 
               this is non-interpolation code. It has some delay in Networking. so i tried to fix this.
Here,
private float lastSynchronizationTime = 0f; private float syncDelay=0f; private float syncTime =0f;
 private Vector3 syncStartPosition = Vector3.zero;
 private Vector3 syncEndPosition = Vector3.zero;
 private Vector3 destinationTile;
 
               void Update(){
     if (Network.isServer) {
         if (MoveDone) {
             if (Turn == 0) {
                 playerList1[0].Move(destinationTile);
 
               public void Move(Vector3 destination){
     if(networkView.isMine)
     {
         MoveSmooth(destination);
     }
     else
     {
         SyncedMovement();
     }
 }
 void MoveSmooth(Vector3 destination){
     destinationTile = destination;
     
     if (Vector3.Distance (transform.position, destination) > 0.3) {
         transform.position += (destination - transform.position).normalized*5*Time.deltaTime;
         if(Vector3.Distance (transform.position, destination) <= 0.3){
             transform.position = destination;
             PlayerManager.instance.MoveDone =false;
             PlayerManager.instance.Turn++;
             if(PlayerManager.instance.Turn == 2)
                 PlayerManager.instance.Turn = 0;
         }
     }
 }
 private void SyncedMovement()
 {
     syncTime += Time.deltaTime;
     transform.position = Vector3.Lerp (syncStartPosition, syncEndPosition, syncTime / syncDelay);
 }
 void OnSerializeNetworkView(BitStream stream,NetworkMessageInfo info){
     Vector3 syncPosition = Vector3.zero;
     if (stream.isWriting)
     {
         syncPosition = transform.position;
         stream.Serialize (ref syncPosition);
     }
     else
     {
         stream.Serialize(ref syncPosition);
         syncTime =0f;
         syncDelay = Time.time - lastSynchronizationTime;
         lastSynchronizationTime = Time.time;
         syncEndPosition = syncPosition + (destinationTile-transform.position).normalized* 10.0f * syncDelay;
         syncStartPosition = transform.position;
     }
 }
 
               I get this in this page http://www.paladinstudios.com/2013/07/10/how-to-create-an-online-multiplayer-game-with-unity/
and i did that tutorial, and this is pretty work. but in my case.
When i see this, this is same! interpolation or not...
so please help me. In Networking, is Interpolation is better than not?
and later I want to upload to Google store. i mean Mobile Circumstance.
Thank you so much for reading my bad bad word!
bye!!
Your answer
 
             Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
Why can't the client move a networked object ? 1 Answer
Connect to remote private IP 1 Answer
Connect to Server on different computer (local network) 0 Answers