Exemplo n.º 1
0
    protected float updateTime = 0.0f;                      //used to time next vision update

    protected virtual void Start()
    {
        boidVision   = GetComponent <BoidVision>();
        boidMovement = GetComponent <BoidMovement>();

        sqrBoidAvoidDistance = behaviourParams.boidAvoidDistance * behaviourParams.boidAvoidDistance;

        float halfBoundsSize = behaviourParams.boundsSize / 2;

        positiveBounds = new Vector3(halfBoundsSize, halfBoundsSize, halfBoundsSize);
        negativeBounds = new Vector3(-halfBoundsSize, -halfBoundsSize, -halfBoundsSize);

        //stagger boid update time by its spawn ID; mod so update time is never more than MAX_UPDATE_TIME
        float mod = (MAX_UPDATE_STAGGER_TIME - BASE_UPDATE_TIME_INTERVAL);

        if (mod <= 0)
        {
            updateTime = 0;
        }
        else
        {
            //updateTime = BASE_UPDATE_TIME_INTERVAL + ((UpdateTimeID / 100f) % mod);
            updateTime = (UpdateTimeID / 100f) % mod;
        }

        Debug.Log(updateTime);
        //TODO: set initial boid velocity
        StartCoroutine(UpdateBoidCoroutine());
    }
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        boidVision   = GetComponent <BoidVision>();
        boidMovement = GetComponent <BoidMovement>();
        rb           = GetComponent <Rigidbody>();

        //set initial boid velocity

        float halfBoundsSize = boundsSize / 2;

        positiveBounds = new Vector3(halfBoundsSize, halfBoundsSize, halfBoundsSize);
        negativeBounds = new Vector3(-halfBoundsSize, -halfBoundsSize, -halfBoundsSize);

        seenBoids     = new List <GameObject>();
        seenObstacles = new List <GameObject>();
    }