Exemple #1
0
    private void Update()
    {
        if (_isOnGround)
        {
            Collider[] agentsWithinDistractorRange = Physics.OverlapSphere(transform.position, Radius, AgentsToDistract);

            foreach (Collider agent in agentsWithinDistractorRange)
            {
                Chicken chicken = agent.gameObject.GetComponent <Chicken>();
                if (chicken.ChickenState == ChickenState.Lured)
                {
                    continue;
                }

                chicken.DistractedTo(this.gameObject);
            }

            if (_rigidbody.velocity != Vector3.zero)
            {
                _rigidbody.velocity = Vector3.zero;
            }
        }

        if (Health == 0)
        {
            Destroy(gameObject);
        }
    }