Exemple #1
0
    IEnumerator MoveCoroutine(LeaderFollower leader)
    {
        while (true)
        {
            leader.MoveChildren();
            yield return(new WaitForSeconds(1));

            leader.StopChildren();
            debugwp.Clear();

            if (Vector3.Distance(leader.agent.agent.transform.position, leader.leaderWP[leader.leaderWP.Count - 1]) < 4)
            {
                leader.MoveLeader();
            }
        }
    }
Exemple #2
0
    void Start()
    {
        List <Vector3> start = new List <Vector3> ();

        start.Add(new Vector3(100, 1, 100));
        start.Add(new Vector3(200, 1, 100));
        start.Add(Vector3.zero);
        start.Add(new Vector3(0, 1, -100));

        List <Model> models = new List <Model> ();

        for (int i = 0; i < totChildren; i++)
        {
            if (modelType == "car")
            {
                if (moveType == "dynamic")
                {
                    models.Add(gameObject.AddComponent <DynamicCarModel> ());
                }
                if (moveType == "kinematic")
                {
                    models.Add(gameObject.AddComponent <KinematicCarModel> ());
                }
            }
            if (modelType == "point")
            {
                if (moveType == "dynamic")
                {
                    models.Add(gameObject.AddComponent <DynamicPointModel> ());
                }
                if (moveType == "kinematic")
                {
                    models.Add(gameObject.AddComponent <KinematicPointModel> ());
                }
                if (moveType == "differential")
                {
                    models.Add(gameObject.AddComponent <DifferentialDriveModel> ());
                }
            }
        }

        LeaderFollower leader = new LeaderFollower("leader", Vector3.zero, null, start);

        leader.doubleChild = true;
        leader.CreateChildren(models);
        if (modelType == "car")
        {
            if (moveType == "dynamic")
            {
                leader.SetModel(gameObject.AddComponent <DynamicCarModel> ());
            }
            if (moveType == "kinematic")
            {
                leader.SetModel(gameObject.AddComponent <KinematicCarModel> ());
            }
        }
        if (modelType == "point")
        {
            if (moveType == "dynamic")
            {
                leader.SetModel(gameObject.AddComponent <DynamicPointModel> ());
            }
            if (moveType == "kinematic")
            {
                leader.SetModel(gameObject.AddComponent <KinematicPointModel> ());
            }
            if (moveType == "differential")
            {
                leader.SetModel(gameObject.AddComponent <DifferentialDriveModel> ());
            }
        }

        leader.MoveLeader();
        StartCoroutine(MoveCoroutine(leader));
    }