title: Object following waypoint constantly rotates
body: <p>I'm trying to make an object move from one point to another in a set path, however once the object reaches the first waypoint it constantly spins around instead of moving to the next point. </p>
  
  <p><strong>Here is my code:</strong></p>
  
  <pre><code>public class Waypoint : MonoBehaviour {
  
     public Transform[] wayPoint = new Transform[9]; 
     int currentWayPoint = 0;
  
     float rotationSpeed = 6.0f;
     public float accelerate = 1.8f;
  
     // Use this for initialization
     void Start () 
     {
      wayPoint[0] = GameObject.Find("Waypoint1").transform;
      wayPoint[1] = GameObject.Find("Waypoint2").transform;
      wayPoint[2] = GameObject.Find("Waypoint3").transform;
      wayPoint[3] = GameObject.Find("Waypoint4").transform;
      wayPoint[4] = GameObject.Find("Waypoint5").transform;
      wayPoint[5] = GameObject.Find("Waypoint6").transform;
      wayPoint[6] = GameObject.Find("Waypoint7").transform;
      wayPoint[7] = GameObject.Find("Waypoint8").transform;
      wayPoint[8] = GameObject.Find("Waypoint9").transform;
     }
  
  // Update is called once per frame
  void Update () 
  {
      if(currentWayPoint == 9)
      {
          Destroy(this.gameObject);
      }
      else
      {
          walk();
      }
  }
  
  void walk()
  {
      Quaternion rotation = Quaternion.LookRotation(wayPoint[currentWayPoint].position - transform.position);
      transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime*rotationSpeed);
  
      Vector3 wayPointDirection = wayPoint[currentWayPoint].position - transform.position;
      float speedElement = Vector3.Dot(wayPointDirection.normalized, transform.forward);
      float speed = accelerate + speedElement;
      transform.Translate(0,0,Time.deltaTime*speed);
  }
  
  void OnTriggerEnter(Collider collider)
  {
      if(collider.tag == "WayPoint")
          currentWayPoint++;  
  }
  </code></pre>
  
  <p>}</p>