title: Syncronize player position in unity (Mirror)
body: <p>Goal: Syncronize player position in a multiplayer game in Unity that uses the Mirror Networking API</p>
  <p>Problem:</p>
  <ol>
  <li><p>Using the NetworkTransform component the position seems to not be precisely syncronized, both the client and the server sees the player in the wrong position, players tend to fly with no reason</p>
  </li>
  <li><p>I tried making a separated script:</p>
  </li>
  </ol>
  <pre><code>
  using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  using Mirror;
  
  public class PlayerSyncronization : NetworkBehaviour
  {
      [SyncVar]
      public Vector3 syncPosition;
      [SyncVar]
      public Quaternion syncRotation;
  
      public float lerpRate = 15;
  
      private void FixedUpdate()
      {
          TransmitPosition();
          Lerp();
      }
      void Lerp()
      {
          if (!hasAuthority) return;
          transform.position = Vector3.Lerp(transform.position, syncPosition, Time.deltaTime * lerpRate);
          transform.rotation = Quaternion.Lerp(transform.rotation, syncRotation, Time.deltaTime * lerpRate);
      }
  
      [ClientCallback]
      void TransmitPosition()
      {
          CmdProvidePositionToServer(transform.position, transform.rotation);
      }
  
      [Command]
      void CmdProvidePositionToServer(Vector3 pos, Quaternion rot)
      {
          syncPosition = pos;
          syncRotation = rot;
      }
  }
  
  </code></pre>
  <p>but the result is the same of the network transform component, and even if a player stops walking, on the other side he keeps walking till he falls off the map</p>
  <p>Those are the errors/warning i got using the script
  <a href="https://i.stack.imgur.com/QNPGc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QNPGc.png" alt="" /></a></p>
  <p>Info:</p>
  <ul>
  <li>Player movement is client side as I'm using root motion.</li>
  <li>I can't use IsLocalPlayer as it works only if the player is directly spawned by the NetworkManger and my players are being spawned by a separated script.</li>
  <li>Right now, even if I'm not using it, i have a CharacterController in my PlayerPrefab</li>
  <li>I'm using Steamworks to make the players connect through internet</li>
  </ul>
  <p>If more info are needed just tell me.</p>