Example #1
0
 void TriggerNextWaypoint()
 {
     if (isLooped)
     {
         currentWaypointIndex = (currentWaypointIndex + 1) % waypoints.Length;
     }
     else
     {
         if (moveBackwards)
         {
             if (currentWaypointIndex == 0)
             {
                 moveBackwards = false;
             }
             currentWaypointIndex++;
         }
         else
         {
             if (currentWaypointIndex == (waypoints.Length - 1))
             {
                 moveBackwards = true;
             }
             currentWaypointIndex--;
         }
     }
     currentWaypoint    = waypoints[currentWaypointIndex];
     currentWaypointPos = initialPos + currentWaypoint.position;
     waitTime           = currentWaypoint.beforeMoveWait;
     isPreMoveWaiting   = true;
 }
Example #2
0
 void Awake()
 {
     initialPos = transform.position;
     if (waypoints.Length > 0)
     {
         currentWaypoint    = waypoints[0];
         currentWaypointPos = initialPos + currentWaypoint.position;
         transform.position = currentWaypointPos;
     }
     else
     {
         currentWaypointPos = initialPos;
     }
     trigger.OnTriggerEnterEvent += OnTriggered;
 }
Example #3
0
 void Awake()
 {
     initialPos = transform.position;
     if (waypoints.Length > 0)
     {
         currentWaypoint    = waypoints[0];
         currentWaypointPos = initialPos + currentWaypoint.position;
         transform.position = currentWaypointPos;
     }
     else
     {
         currentWaypointPos = initialPos;
     }
     foreach (var o in spikes)
     {
         o.OnTriggerEnterEvent += OnSpikesTriggered;
     }
 }