コード例 #1
0
    public override void Initialize()
    {
        print("Initializing : PedestrianWorldBehavior");


        for (int i = 0; i < numPedestrians / 2; i++)
        {
            {
                AAgent a = CreateAgent(world, pedestrian);
                PedestrianWalkBehavior pwb = a.GetComponent <PedestrianWalkBehavior> ();

                pwb.Direction        = Vector3.right;
                a.transform.position = new Vector3(-10, 0, (Random.value - 0.5f) * 10);
                pwb.Speed            = Random.Range(minSpeed, maxSpeed);
            }
            {
                AAgent a = CreateAgent(world, pedestrian);
                PedestrianWalkBehavior pwb = a.GetComponent <PedestrianWalkBehavior> ();

                pwb.Direction        = Vector3.left;
                a.transform.position = new Vector3(10, 0, (Random.value - 0.5f) * 10);
                pwb.Speed            = Random.Range(minSpeed, maxSpeed);
            }
        }
    }
コード例 #2
0
    public override void Step()
    {
        if ((counter++) % waitSteps != 0)
        {
            return;
        }

        if (num < number)
        {
            AAgent pref = factory.GetAWalker();
            AAgent a    = CreateAgent(AttachedWorld, pref);

            SpawningPoint[] sps2 = sps.Where(x => x.spawnHere).ToArray();

            int i = Random.Range(0, sps2.Length);
            UnityEngine.AI.NavMeshAgent nma = a.GetComponent <UnityEngine.AI.NavMeshAgent> ();
            if (nma)
            {
                nma.enabled = false;
            }

            a.transform.position = sps2 [i].transform.position;
            a.transform.Translate(new Vector3(Random.Range(-3f, 3f), 0, Random.Range(-3f, 3f)));

            if (nma)
            {
                nma.enabled = true;
            }

            num++;
        }

        //print ("Pedestrian Counts : " + num);
    }
コード例 #3
0
    public override void Initialize()
    {
        int radius = 10;

        for (float i = 0; i < 360; i += 360 / 100f)
        {
            AAgent a = CreateAgent(AttachedWorld, toriPref.AttachedAgent);
            a.transform.position = new Vector3(Mathf.Cos(i) * radius, 0, Mathf.Sin(i) * radius);
            a.transform.LookAt(Vector3.zero);
            a.GetComponent <SpeedDirectionBehavior>().Direction = a.transform.forward;
        }
    }