I saw this issue in the previous topics, and as it is explained, the method FindGameObjectsWithTag not always returns an ordered array. Of course, the problem is addressed in future lectures.
However, in the meantime, if you want to see a well-mannered enemy, walking through the path from beginning to end (not a crazy one, moving diagonally, stepping on the grass and moving backwards), you can use this temporary workaround in the method FindPath:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq; // don't forget this line
...
void FindPath()
{
path.Clear();
// A workaround to avoid an irregular travel of the enemy because of an unorderer array
GameObject[] waypoints = GameObject.FindGameObjectsWithTag("Path").OrderBy(w => w.transform.position.z).OrderBy(w => w.transform.position.x).ToArray();
foreach(GameObject waypoint in waypoints)
path.Add(waypoint.GetComponent<Waypoint>());
}
...
It is just a workaround for this particular path.
If your enemy needs to move to the left or downwards, it won’t work.