Hey, so what I'd like to do is make an array of children, then move the player to the child in the the array that I choose, heres the code; WayPointContainer is an empty gameobject with empty gameObjects as children.
var WayPoints = new Array();
var WayPointContainer : Transform;
private var CurrentWayPoint : int = 1;
function Start ()
{
WayPoints.Add(WayPointContainer.GetComponentsInChildren(Transform));
Debug.Log(WayPoints[CurrentWayPoint].position);
}
function Update ()
{
if(transform.position.x != WayPoints[CurrentWayPoint].position.x)
{
//move
}
}
the error I get is ; ArgumentOutOfRangeException: Index is less than 0 or more than or equal to the list count. Parameter name: index 1
does this mean it isn't adding the transforms of the children? if so how do I fix this?