Make ai follow the player?

I am currently working on a test ai, I want it to follow the player. I got a working one, however I was updating the path too suddenly, which causes the ai to freeze and not move. This is the code I am using, what is a better way of making the ai follow the player?
`using UnityEngine;
using System.Collections;
using Pathfinding;
public class neww : MonoBehaviour
{
public Vector3 targetPosition;
private Seeker seeker;
private CharacterController controller;
public Path path;
public float speed = 100;
public float nextWaypointDistance = 3;
private int currentWaypoint = 0;
private bool chasePlayer = true;
private Vector3 oldPosition;

public void Start()
{

    StartCoroutine(WaitTime());
    oldPosition = GameObject.Find("Player").transform.position;
}


IEnumerator WaitTime()
{
    while (chasePlayer == true)
    {
        Debug.Log("loop is working");
        targetPosition = GameObject.Find("Player").transform.position;
        if (oldPosition != targetPosition)
        {
            oldPosition = targetPosition;
            seeker = GetComponent<Seeker>();
            controller = GetComponent<CharacterController>();
            seeker.StartPath(transform.position, targetPosition, OnPathComplete);
            Debug.Log("working");
        }
        yield return new WaitForSeconds(0.2f);
    }

}
public void OnPathComplete(Path p)
{
    Debug.Log("Yay, we got a path back. Did it have an error? " + p.error);
    if (!p.error)
    {
        path = p;
        currentWaypoint = 0;
    }
}
public void FixedUpdate()
{
    if (path == null)
    {
        return;
    }
    if (currentWaypoint >= path.vectorPath.Count)
    {
        //Debug.Log("End Of Path Reached");
        return;
    }
    Vector3 dir = (path.vectorPath[currentWaypoint] - transform.position).normalized;
    dir *= speed * Time.fixedDeltaTime;
    controller.SimpleMove(dir);
    if (Vector3.Distance(transform.position, path.vectorPath[currentWaypoint]) < nextWaypointDistance)
    {
        currentWaypoint++;
        return;
    }
}

}
`

Hi

What does the path log say? (enable at A* Inspector -> Settings -> Path Log Mode).
It might be because you are requesting the path too often. My advice would be to wait with requesting a new path until you know the previous one has been completely calculated. You can do this using
seeker.IsDone ()

Hi, thanks for the reply. That is the problem I think is occurring, I set it to loop over and over again to update the path/check were the player is to follow them. I am really just wondering though if I am doing it the correct way or if there is a better way to just have the ai follow the player without having to constantly re-send a new path.