Make NPC travel to waypoint

I’ve been trying to make an NPC travel through a series of waypoints and stop at the end of an array.

I started by making the NPC target a single waypoint and move toward int however, i receive these errors when I run the game:

NullReferenceException: Object reference not set to an instance of an object
NPCMove.Start () (at Assets/Scripts/AI/NPCMove.cs:19)

UnassignedReferenceException: The variable target of ‘NPCMove’ has not been assigned.
You probably need to assign the target variable of the NPCMove script in the inspector.
UnityEngine.Transform.get_position ()
NPCMove.Update () (at Assets/Scripts/AI/NPCMove.cs:24)

public class NPCMove : MonoBehaviour {
	public Transform target;
	public int moveSpeed;
	public int rotationSpeed;

	private Transform myTransform;
	private Transform stopDistance;

	void Awake(){
		myTransform = transform;

	// Use this for initialization
	void Start () {
		GameObject go = GameObject.FindGameObjectWithTag("WayPoint");
		target = go.transform;
	// Update is called once per frame
	void Update () {
		Debug.DrawLine(target.position, myTransform.position,;

		//look at
		myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed * Time.deltaTime);

		myTransform.position += myTransform.forward *moveSpeed * Time.deltaTime;

Also, how would I make this use an array.

There is no “gameObject.FindGameObjectWithTag”, only “gameObject.FindWithTag”. After that it should work(at least these errors should be gone).

To use an array you have to create one, and loop through it. You can get an array of GO’s by


Keep in mind this will return every GO with a certain tag which will break the system if you have multiple agents.