Пример #1
0
    public void updateEntries()
    {
        int layerIndex = LayerMask.NameToLayer("Animal");
        int layerMask  = 1 << layerIndex;

        Collider[] colliders = Physics.OverlapSphere(self.getPosition(), self.getSighDistance() + 10.0f, layerMask);
        AnimalAI   animal;

        foreach (Collider collider in colliders)
        {
            animal = null;
            animal = collider.GetComponent <AnimalAI>();
            if (animal != null && animal != self && !entries.Keys.Contains(animal))
            {
                float angleToTarget = Vector3.Angle(collider.transform.position - self.getHeadPosition(), self.transform.forward);
                if (angleToTarget <= self.getFov() / 2 && hasLineOfSight(collider as BoxCollider))
                {
                    register(animal);
                }
            }
        }
    }