コード例 #1
0
    // Use this for initialization
    void Start()
    {
        //if (!NA.isClient())
        //local mode
        {
            velocity = new Vector3();
            //velocity = UnityEngine.Random.onUnitSphere * 2.0f;
            //transform.forward = velocity;


            acceleration = new Vector3();


            neighborhood = new List <SteeringVehicle>();

            behaviors = new List <SteeringBehavior>();

            behaviors.Add(new Separation(this, steeringWeightSeparation));
            behaviors.Add(new Cohesion(this, steeringWeightCohesion));
            behaviors.Add(new Alignment(this, steeringWeightAlignment));

            steerPerch = new Arrival(this, steeringWeightHoming, target, 2.0f);
            PickNewPerch();

            behaviors.Add(steerPerch);
            if (flockManager != null)
            {
                flockManager.AddVehicle(this);
            }
        }
    }
コード例 #2
0
    void Activate()
    {
        velocity = new Vector3();
        //velocity = UnityEngine.Random.onUnitSphere * 2.0f;
        //transform.forward = velocity;


        acceleration = new Vector3();


        neighborhood = new List <SteeringVehicle>();

        behaviors = new List <SteeringBehavior>();

        behaviors.Add(new Separation(this, steeringWeightSeparation));
        behaviors.Add(new Cohesion(this, steeringWeightCohesion));
        behaviors.Add(new Alignment(this, steeringWeightAlignment));

        steerPerch = new Arrival(this, steeringWeightHoming, target, 2.0f);
        PickNewPerch();

        behaviors.Add(steerPerch);
        if (flockManager != null)
        {
            flockManager.AddVehicle(this);
        }

        GetComponent <AudioSource>().enabled = true;
        vehicleActive = true;
    }