void Start()
    {
        Selector             TreeRoot         = new Selector();
        Sequence             Patrol           = new Sequence();
        MoveTo               MoveToWP         = new MoveTo();
        PlayerChangeLane     playerChangeLane = new PlayerChangeLane();
        SelectNextGameObject PickNextWP       = new SelectNextGameObject();


        //TurnSpeed = 2.0f;
        //Speed = 5.0f;
        //Accuracy = 1.5f;
        SetValue("TurnSpeed", TurnSpeed);
        SetValue("Speed", Speed);
        SetValue("Accuracy", Accuracy);
        SetValue("Direction", 1);

        MoveToWP.TargetName      = "Waypoint";
        PickNextWP.ArrayKey      = "Waypoints";
        PickNextWP.GameObjectKey = "Waypoint";
        PickNextWP.IndexKey      = "Index";
        PickNextWP.DirectionKey  = "Direction";

        Patrol.children.Add(MoveToWP);
        Patrol.children.Add(PickNextWP);
        Patrol.children.Add(playerChangeLane);
        TreeRoot.children.Add(Patrol);
        Patrol.tree           = this;
        TreeRoot.tree         = this;
        MoveToWP.tree         = this;
        playerChangeLane.tree = this;
        PickNextWP.tree       = this;
        root = TreeRoot;
    }
    // Start is called before the first frame update
    void Start()
    {
        Selector             TreeRoot        = new Selector();
        Sequence             TrackRace       = new Sequence();
        SelectNextGameObject SelectNextPoint = new SelectNextGameObject();
        MoveTo           MoveToObject        = new MoveTo();
        PlayerChangeLane ChangeLange         = new PlayerChangeLane();

        SetValue("Catmul", catmul.sp);
        SetValue("CurrentPoint", catmul.sp[0]);
        SetValue("CurrentPointIndex", 0);
        //Default is going forwards along the path
        SetValue("Direction", 1);
        SetValue("TrackManager", trackManager);
        SetValue("TrackIndex", trackIndex);
        SetValue("TurnRequested", Turning.STRAIGHT);

        SetValue("Speed", 5.0f);
        SetValue("TurnSpeed", 2.0f);
        SetValue("Accuracy", 1.5f);

        SelectNextPoint.ArrayKey      = "Catmul";
        SelectNextPoint.GameObjectKey = "CurrentPoint";
        SelectNextPoint.IndexKey      = "CurrentPointIndex";
        SelectNextPoint.DirectionKey  = "Direction";
        MoveToObject.TargetName       = "CurrentPoint";
        ChangeLange.IndexKey          = "CurrentPointIndex";
        ChangeLange.GameObjectKey     = "CurrentPoint";
        ChangeLange.ArrayKey          = "Catmul";

        TrackRace.children.Add(SelectNextPoint);
        TrackRace.children.Add(MoveToObject);
        TrackRace.children.Add(ChangeLange);
        TreeRoot.children.Add(TrackRace);
        TrackRace.tree       = this;
        SelectNextPoint.tree = this;
        MoveToObject.tree    = this;
        ChangeLange.tree     = this;
        TreeRoot.tree        = this;
        root = TreeRoot;
    }
    // Use this for initialization
    void Start()
    {
        maskNames = new string[5][];

        maskNames[0] = new string[] { "flock1", "flock2", "flock3", "flock4" };
        maskNames[1] = new string[] { "flock0", "flock2", "flock3", "flock4" };
        maskNames[2] = new string[] { "flock0", "flock1", "flock3", "flock4" };
        maskNames[3] = new string[] { "flock0", "flock1", "flock2", "flock4" };
        maskNames[4] = new string[] { "flock0", "flock1", "flock2", "flock3" };
        splines      = new Catmul[5]; // TODO - change
        splines[0]   = Instantiate(splinePrefab, new Vector3(0, 0, 0), Quaternion.identity).GetComponent <Catmul>();
        splines[1]   = Instantiate(splinePrefab, new Vector3(30, 0, 30), Quaternion.identity).GetComponent <Catmul>();
        splines[2]   = Instantiate(splinePrefab, new Vector3(30, 0, -30), Quaternion.identity).GetComponent <Catmul>();
        splines[3]   = Instantiate(splinePrefab, new Vector3(-30, 0, 30), Quaternion.identity).GetComponent <Catmul>();
        splines[4]   = Instantiate(splinePrefab, new Vector3(-30, 0, -30), Quaternion.identity).GetComponent <Catmul>();
        // TODO add code here

        for (int i = 0; i < splines.Length; i++) // TO DO - change code
        {
            splines[i].gameObject.tag = "track" + i.ToString();
            splines[i].GenerateSpline();
        }
        // spawn the flocks on the tracks.  Track 0 is where the player begins.
        for (int i = 0; i < swarmleaderPrefab.Length; i++) // TO DO CHANGE CODE
        {
            // TO DO - Spawn the swarm leader
            // TODO - Get the follow track script, and tell it about the track manager (so it can find more tracks), and the spline.
            // make sure to set the mask on the flock, and to say which is the player.

            // = Instantiate(swarmleaderPrefab[i], Vector3.zero, Quaternion.identity);

            GameObject leader = Instantiate(swarmleaderPrefab[i], splines[i].firstPoint, Quaternion.identity);
            if (i == 0)
            {
                leader.tag = "Player";
            }
            //else
            {
                BehaviorTree bt = leader.GetComponent <BehaviorTree>();

                Sequence sq = new Sequence();
                bt.root = sq;

                SelectNextGameObject select = new SelectNextGameObject();
                select.ArrayKey      = "array";
                select.IndexKey      = "index";
                select.GameObjectKey = "currentObject";
                select.DirectionKey  = "direction";
                select.tree          = bt;

                MoveTo mt = new MoveTo();
                mt.TargetName = "currentObject";
                mt.tree       = bt;

                SetTrack st = new SetTrack();
                st.ArrayKey     = "array";
                st.IndexKey     = "index";
                st.DirectionKey = "direction";

                sq.children.Add(select);
                sq.children.Add(mt);
                sq.children.Add(st);

                bt.AddKey("array", splines[i].PointObjects);
                bt.AddKey("index", 1);
                bt.AddKey("currentObject", splines[i].PointObjects[1]);
                bt.AddKey("direction", 1);
                bt.AddKey("Speed", 10.0f);
                bt.AddKey("TurnSpeed", 10.0f);
                bt.AddKey("Accuracy", 1.5f);
            }
        }
    }