Ejemplo n.º 1
0
    /**
     * Work out what the next waypoint is going to be
     *
     */
    private void NextWaypoint()
    {
        if (isCircular)
        {
            if (!inReverse)
            {
                currentIndex = (currentIndex + 1 >= wayPoints.Length) ? 0 : currentIndex + 1;
            }
            else
            {
                currentIndex = (currentIndex == 0) ? wayPoints.Length - 1 : currentIndex - 1;
            }
        }
        else
        {
            // If at the start or the end then reverse
            if ((!inReverse && currentIndex + 1 >= wayPoints.Length) || (inReverse && currentIndex == 0))
            {
                inReverse = !inReverse;
            }
            currentIndex = (!inReverse) ? currentIndex + 1 : currentIndex - 1;
        }

        currentWaypoint = wayPoints[currentIndex];
    }
Ejemplo n.º 2
0
 // Use this for initialization
 void Start()
 {
     if (wayPoints.Length > 0)
     {
         currentWaypoint = wayPoints[0];
     }
 }