Not sure if the StartCoroutine make the stuttering. But when disable the script not to use it in the Inspector the stuttering is gone when using the script it happen.
I'm using a waypoints script attached to ThirdPersonController. I added to the ThirdPersoncontroller also Nav MesH Agent.
I have in the Hierarchy also two Spheres as waypoints in the Naviagtion window i ticked on the checkbox to make them Navigation Static also i did Navigation Static on a Plane.
Then Baked it.
In the Animator window i created new state Walk using HumanoidWalk and set is default so all players start walking automatic when running the game.
The player is walking between the waypoints but it's all stuttering. If i'm not using the script the player is walking fine also other players i have walking fine only when using the script it's stuttering.
This is the waypoints script:
using UnityEngine;
using System.Collections;
public class Patrol : MonoBehaviour
{
public Transform[] patrolPoints;
private NavMeshAgent agent;
private int dest = 0;
// Use this for initialization
void Start()
{
agent = GetComponent<NavMeshAgent> ();
StartCoroutine (Patrolling ());
}
IEnumerator Patrolling()
{
bool startPatorl = false;
for (int i = 0; i < patrolPoints.Length; i++)
{
while (!startPatorl)
{
if (agent.remainingDistance < 2.5f)
{
i++;
dest = i;
}
if (i >= patrolPoints.Length)
{
i = 0;
dest = 0;
}
agent.destination = patrolPoints[dest].transform.position;
yield return null;
}
}
}
}