Exemple #1
0
    void Update()
    {
        velocity           += SB.Arrive(this, target, 3);
        velocity           += SB.Flee(this, target, 1);
        velocity           += SB.Separate(this, GameManager.agents, 2f);
        transform.position += velocity * Time.deltaTime;

        /*  for (int i = 0; i < target.Length; i++) {
         *               float angle = 360 * i ;
         *               float posX = transform.position.x + Mathf.Sin (angle * Mathf.Deg2Rad) * Radio;
         *               float posY = transform.position.y + Mathf.Cos (angle * Mathf.Deg2Rad) * Radio;
         *               target [i].position = new Vector3 (posX, posY);
         * }*/
    }
Exemple #2
0
    void Update()
    {
        velocity           += SB.Arrive(this, target, 3);
        velocity           += SB.Flee(this, target, 1);
        velocity           += SB.Separate(this, GameManager.agents, 2f);
        transform.position += velocity * Time.deltaTime;

        if (transform.position.y < -2 || transform.position.y > 2)
        {
            velocity.y *= 0;
        }

        if (transform.position.x < -2 || transform.position.x > 2)
        {
            velocity.x *= 0;
        }
    }