title: How can i make array of ThirdPersonController in the Hierarchy and add Waypoint?
body: <p>What i did is added one ThirdPersonConctroller then in menu i clicked on Window > Animator. Created Empty State called it Walk. The state is set to HumandoidWalk.</p>
  
  <p>Then i added to the Hierarchy another ThirdPersonController and bit different position on the x. Now when running the game both ThirdPersonController walking.</p>
  
  <p>Now i changed the second ThirdPersonController move speed to 2 so it's walking faster then the first one.</p>
  
  <p>Now i wonder how to do two main things:</p>
  
  <p>If i wanted to make 10 ThirdPersonController in the Hierarchy i could drag over and over again new ThirdPersonController from the Assets > Characters > ThirdPersoncharacter > Prefabs but that's a lot of work. I wonder if there is way to do it in c# script or other way to make array of ThirdPersonController ?</p>
  
  <p>I want to make one waypoint so when the ThirdPersonController will get there he will turn around 180degrees and will walk back to it's origian position. And if one of the ThirdPersonController is walking faster he will turn back faster. But the idea is that both ThirdPersonController will get to the same position of theire x and will turn back.</p>
  
  <p>For exmaple the first ThirdPersonController is on x = 0 y = 0 z = 0 so when he walk and get to z = 100 only z change then turn around back to z = 0</p>
  
  <p>The other ThirdPersonController is on x = -1.539 y = 0 z = 0 so this time also only z change to 100 when he get to 100 to turn around back to z = 0</p>
  
  <p><a href="https://i.stack.imgur.com/zDJCH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zDJCH.jpg" alt="Screenshot"></a></p>
  
  <p>I have this working waypoints script in c#
  The problem is that now bothp layers walking one behind the other to the waypoints and i wanted to do as before that the second player will walk beside the first one and a bit faster then the first one.</p>
  
  <p>Before i did changes in the move speed and position of the second ThirdPersonController(1) in the Inspector changed the move speed to 2 and the changed the position to -1.537 but after adding the waypoints script they bot walking on same speed and one behind the other.</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  public class Waypoints : MonoBehaviour {
  
      public Transform[] waypoint;
      public float patrolSpeed;
      public bool loop = true;
      public int dampingLook = 4;
      public float pauseDuration;
      private float curTime;
      private int currentWaypoint = 0;
      public CharacterController character;
  
      // Use this for initialization
      void Start () {
  
  
      }
  
      void LateUpdate(){
  
          if(currentWaypoint &lt; waypoint.Length){
              patrol();
          }else{    
              if(loop){
                  currentWaypoint=0;
              } 
          }
      }
  
      void patrol(){
  
          Vector3 nextWayPoint = waypoint[currentWaypoint].position;
  
          // Keep waypoint at character's height
          nextWayPoint.y = transform.position.y; 
  
          // Get the direction we need to move to
          // reach the next waypoint
          Vector3 moveDirection = nextWayPoint - transform.position;
  
  
          if(moveDirection.magnitude &lt; 1.5){
              Debug.Log("enemy is close to nextwaypoint");
  
  
              // This section of code is called only whenever the enemy
              // is very close to the new waypoint 
              // so it is called once after 4-5 seconds.
  
              if (curTime == 0)
                  // Pause over the Waypoint 
                  curTime = Time.time; 
  
              if ((Time.time - curTime) &gt;= pauseDuration){
                  Debug.Log("increasing waypoint");
  
                  currentWaypoint++;
                  curTime = 0;
              }
          }
          else
          {     
              Debug.Log("reaching in rotation " + moveDirection.magnitude);
              // This code gets called every time update is called
              // while the enemy if moving from point 1 to point 2.
              // so it gets called 100's of times in a few seconds  
  
              // Now we need to do two things
              // 1) Start rotating in the desired direction
              // 2) Start moving in the desired direction 
  
              // 1) Let' calculate rotation need to look at waypoint
              // by simply comparing the desired waypoint &amp; current transform
              var rotation = Quaternion.LookRotation(nextWayPoint - transform.position);
  
              // A slerp function allow us to slowly start rotating 
              // towards our next waypoint 
              transform.rotation = Quaternion.Slerp(transform.rotation, rotation, 
                  Time.deltaTime * dampingLook);
  
              // 2) Now also let's start moving towards our waypoint
              character.Move(moveDirection.normalized * patrolSpeed * Time.deltaTime);
          }  
      }
  }
  </code></pre>