When testing this with 2 instances of the game running I notice that the tank units on the client instance no longer move, where as the host is working as expected. Below is my movement script.
Im using Unity version 2020.2.2
public class UnitMovement : NetworkBehaviour
{
[SerializeField] private NavMeshAgent agent = null;
[SerializeField] private Targetter targetter = null;
[SerializeField] float chaseRange = 10f;
#region server
[ServerCallback]
private void Update()
{
Targetable target = targetter.GetTarget();
if(target != null)
{
if((target.transform.position - transform.position).sqrMagnitude > chaseRange * chaseRange)
{
agent.SetDestination(target.transform.position);
}
else if(agent.hasPath)
{
agent.ResetPath();
}
return;
}
if(!agent.hasPath){return;}
if(agent.remainingDistance > agent.stoppingDistance){return;}
agent.ResetPath();
}
[Command]
public void CmdPlayerMove(Vector3 position)
{
targetter.ClearTarget();
if(!NavMesh.SamplePosition(position, out NavMeshHit hit, 1f, NavMesh.AllAreas))return;
agent.SetDestination(hit.position);
}
#endregion
#region client
#endregion
}