2D grid simple follow ai pathfinding help?

Hi, I’m new to A* Pathfinding Project but am really impressed with it! I want to use it to simplify the ai for a legend of zelda or binding of isaac’esc real time 2d top down game. Right now I’m just trying to get an enemy to follow the hero around the screen. His path needs to go around walls and such and update as the player moves. I know I am very close to a working solution.

Right now the problem is that the enemy follows the hero but occasionally decides to go in reverse along the path. My underlying code uses an A* grid graph, as well as a seeker script on the enemy. My script starts searching for a path every time a path is not being searched for. Then in the OnPathComplete method, I save off the path and tell my enemy to move along the path via velocity (physics2D). I only ever tell the enemy to move towards the first point along the path because a new path is calculated so often that it shouldn’t matter (that being said I have tried a more complicated full path follow approach and have had the same ‘reverse path’ problem). Heres the code, any help is GREATLY appreciated!

void Update () {
if (currentlySearchingForPath == false) {
SearchPath ();
}
}

public void SearchPath () {
Seeker seeker = GetComponent();

// Start a new path request
// When the path has been calculated, it will be returned to the function OnPathComplete unless it was canceled by another path request
seeker.StartPath (transform.position, oMoveTarget.transform.position, OnPathComplete);

currentlySearchingForPath = true;

}

public void OnPathComplete (Path p) {
//We got our path back
if (p.error) {
// Nooo, a valid path couldn’t be found
} else {
// Yay, now we can get a Vector3 representation of the path
// from p.vectorPath
path = p.vectorPath;
currentlySearchingForPath = false;
timeSincePath = Time.fixedTime;

  Vector2 startPoint = transform.position;
  Vector2 endPoint = path [1];

  Vector2 dirVector = endPoint - startPoint;

  GetComponent<Rigidbody2D> ().velocity += dirVector / dirVector.magnitude * (GetComponent<Unit> ().fMoveSpeed * DtCon.Game.fActionSpeedMultiplier);

}
}

Ps. One thought I had was that transform.position is getting a value from a previous frame somehow because the lines drawn from the pathfinding project’s gizmo show the path starting from a way’s back from where the enemy is actually at.