add waypoint to transform[]

Hey, Im trying to add a new gameObject (empty) to a transform array thing (Im not to knowledgeable on how arrays work/what they are) and have a bot patrol between these empties, heres the code;

    var WayPoint : Transform[];
    private var CurrentWayPoint : int;
    var Speed : float = 20.0;

Awake() VVVVVVV

WayPoint[0] = transform;

Update() VVVVVVV

            if(CurrentWayPoint < WayPoint.length)
            {
                var target : Vector2 = WayPoint[CurrentWayPoint].position;
                var moveDirection : Vector2 = target - transform.position;
                var velocity = rigidbody.velocity;
                if(moveDirection.magnitude < 1)
                {
                    CurrentWayPoint++;
                }
                else
                {
                    velocity = moveDirection.normalized * Speed;
                }
            }
            else
            {
                if( loop )
                {
                    CurrentWayPoint = 0;
                }
                else
                {
                    velocity = Vector3.zero;
                }
            }
            rigidbody.velocity = velocity;

Now, this is the new waypoint;

var NewWayPoint = new GameObject("EnemyWayPoint3");

I'm not 100% sure what you need but I figure you're asking how to add an element to a built-in array of predefined size. I wrote a simple example not long ago, here it is:

var myWPs:Transform[] = new Transform[9];
function AddWP(wp:Transform){
    var buffer:Transform[] = myWPs;
    myWPs = new Transform[buffer.length+1];
    for(i=0;i<buffer.length;i++){ myWPs _= buffer*; }*_
 _*myWPs[myWPs.length-1] = wp;*_
_*}*_
_*```*_

I think this great tutorial might help you with exactly what you want. Go to step 5.

Now as to adding waypoint to an array. I assume that in your hierarchy view you have one empty gameobject (at 0,0,0) called waypoints. Childed to this empty container are all your waypoints. Have all these waypoints in alphabetical order as you want them to come up. For instance waypoint1, waypoint2, etc. Or just 1,2,3...

In your script use GetComponentsInChildren

nameofyourarray = nameofthewaypointscontainer.GetComponentsInChildren(Transform);

to add the transform of the container and all of its children (the waypoints) in that order in an array. Now you'll want to remove the first transform - the one of the useless container. Use Shift

nameofyourarray.Shift();

Now your array has all of the transforms of all your waypoints in the correct order. Reference them using

nameofyourarray[numberofthewaypoint].position

Good luck!