Example #1
0
 private void Update()
 {
     if (!isFinished)
     {
         if (lastWaypoint + 1 < trackHolder.trackPoints.Length) //Haven't reached the end yet
         {
             nextWaypoint         = trackHolder.trackPoints[lastWaypoint + 1];
             nextWaypointDistance = Vector3.Distance(transform.position, nextWaypoint.transform.position);
         }
         else
         {
             //GOOOOAAAAAAAAALLLLL
             ranks.winners.Add(this);
             isFinished = true;
         }
     }
 }
    public void OnTriggerEnter(Collider other)
    {
        WaypointIndex waypoint = other.GetComponent <WaypointIndex>();

        if (waypoint == null)
        {
            return;
        }

        if (m_recentWaypointIndex + 1 == waypoint.m_index)
        {
            m_recentWaypointIndex = waypoint.m_index;
        }
        else if (m_recentWaypointIndex == WaypointIndex.INDEX_MAX && waypoint.m_index == 0)
        {
            m_recentWaypointIndex = 0;
            ++m_lapCount;
        }
    }