コード例 #1
0
        public override void OnTriggerEvent(AITriggerEventType eventType, Collider other)
        {
            if (eventType == AITriggerEventType.Enter)
            {
                if (Utilities_AI.checkIfPlayer(other.gameObject))
                {
                    if (!lookAtPlayer)
                    {
                        stateMachine.LookAtThis = null;
                    }
                    else
                    {
                        stateMachine.LookAtThis = other.gameObject;
                    }
                }
            }
            else if (eventType == AITriggerEventType.Exit)
            {
                if (Utilities_AI.checkIfPlayer(other.gameObject))
                {
                    stateMachine.LookAtThis = null;
                }
            }

            base.OnTriggerEvent(eventType, other);
        }
コード例 #2
0
 // ------------------------------------------------------------
 // Name :   OnTriggerEvent
 // Desc :   Called by our AISensor component when an AI Aggravator
 //          has entered/exited the sensor trigger.
 // -------------------------------------------------------------
 public virtual void OnTriggerEvent(AITriggerEventType type, Collider other)
 {
     if (_currentState != null)
     {
         _currentState.OnTriggerEvent(type, other);
     }
 }
コード例 #3
0
 public virtual void OnCollisionEvent(AITriggerEventType type, Collision collision)
 {
     if (currentState)
     {
         currentState.OnCollisionEvent(eventType: type, other: collision);
     }
 }
コード例 #4
0
 public virtual void OnTriggerEvent(AITriggerEventType type, Collider other)
 {
     if (currentState)
     {
         currentState.OnTriggerEvent(eventType: type, other: other);
     }
 }
コード例 #5
0
    public override void OnTriggerEvent(AITriggerEventType eventType, Collider other)
    {
        if (_npcStateMachine == null)
        {
            return;
        }

        if (eventType != AITriggerEventType.Exit)
        {
            AITargetType curType = _npcStateMachine.VisualThreat.type;

            if (other.CompareTag("Player"))
            {
                float distance = Vector3.Distance(_npcStateMachine.sensorPosition, other.transform.position);
                if (curType != AITargetType.Visual_Player || (curType == AITargetType.Visual_Player && distance < _npcStateMachine.VisualThreat.distance))
                {
                    RaycastHit hitInfo;
                    if (ColliderIsVisible(other, out hitInfo, _playerLayerMask))
                    {
                        _npcStateMachine.VisualThreat.Set(AITargetType.Visual_Player, other, other.transform.position, distance);
                    }
                }
            }
            else if (other.CompareTag("AI Sound Emitter"))
            {
                SphereCollider soundTrigger = (SphereCollider)other;
                if (soundTrigger == null)
                {
                    return;
                }

                Vector3 agentSensorPosition = _npcStateMachine.sensorPosition;
                Vector3 soundPos;
                float   soundRadius;
                AIState.ConvertSphereColliderToWorldSpace(soundTrigger, out soundPos, out soundRadius);
                float distanceToThreat = (soundPos - agentSensorPosition).magnitude;
                float distanceFactor   = (distanceToThreat / soundRadius);

                // Too far away
                if (distanceFactor > 1.0f)
                {
                    return;
                }

                if (distanceToThreat < _npcStateMachine.AudioThreat.distance)
                {
                    _npcStateMachine.AudioThreat.Set(AITargetType.Audio, other, soundPos, distanceToThreat);
                }
            }
        }
    }
 /// <summary>
 ///     When the collider is entered
 /// </summary>
 /// <param name="eventType"></param>
 /// <param name="other"></param>
 public override void OnTriggerEvent(AITriggerEventType eventType, Collider other)
 {
     if (eventType == AITriggerEventType.Enter)
     {
     }
     else if (eventType == AITriggerEventType.Stay)
     {
         CheckSurroundings();
     }
     else if (eventType == AITriggerEventType.Exit)
     {
         //if ( other.gameObject.CompareTag( "Player" ) )
         //{
         //    stateMachine.LookAtThis = null;
         //}
     }
     base.OnTriggerEvent(eventType, other);
 }
コード例 #7
0
 public virtual void OnTriggerEvent(AITriggerEventType eventType, Collider other)
 {
 }
コード例 #8
0
ファイル: AIZombieState.cs プロジェクト: Auggst/FPS-Demo
    public override void OnTriggerEvent(AITriggerEventType eventType, Collider other)
    {
        //base.OnTriggerEvent(eventType, other);
        if (_zombieStateMachine == null)
        {
            return;
        }
        if (eventType != AITriggerEventType.Exit)
        {
            AITargetType curType = _zombieStateMachine.VisualThreat.type;

            if (other.CompareTag("Player"))
            {
                float distance = Vector3.Distance(_zombieStateMachine.sensorPosition, other.transform.position);
                if (curType != AITargetType.Visual_Player ||
                    (curType == AITargetType.Visual_Player && distance < _zombieStateMachine.VisualThreat.distance))
                {
                    RaycastHit hitInfo;
                    if (ColliderIsVisible(other, out hitInfo, _playerLayerMask))
                    {
                        _zombieStateMachine.VisualThreat.Set(AITargetType.Visual_Player, other, other.transform.position, distance);
                    }
                }
            }
            else
            if (other.CompareTag("Flash Light") && curType != AITargetType.Visual_Player)
            {
                BoxCollider flashLightTrigger = (BoxCollider)other;
                float       distanceToThreat  = Vector3.Distance(_zombieStateMachine.sensorPosition, flashLightTrigger.transform.position);
                float       zSize             = flashLightTrigger.size.z * flashLightTrigger.transform.lossyScale.z;
                float       aggrFactor        = distanceToThreat / zSize;
                if (aggrFactor < _zombieStateMachine.sight && aggrFactor <= _zombieStateMachine.intelligence)
                {
                    _zombieStateMachine.VisualThreat.Set(AITargetType.Visual_Light, other, other.transform.position, distanceToThreat);
                }
            }
            else if (other.CompareTag("AI Sound Emitter"))
            {
                SphereCollider soundTrigger = (SphereCollider)other;
                if (soundTrigger == null)
                {
                    return;
                }

                Vector3 agentSensorPosition = _zombieStateMachine.sensorPosition;

                Vector3 soundPos;
                float   soundRadius;
                AIState.ConvertSphereColliderToWorldSpace(soundTrigger, out soundPos, out soundRadius);

                float distanceToThreat = (soundPos - agentSensorPosition).magnitude;

                float distanceFactor = (distanceToThreat / soundRadius);

                distanceFactor += distanceFactor * (1.0f - _zombieStateMachine.hearing);

                if (distanceFactor > 1.0f)
                {
                    return;
                }

                if (distanceToThreat < _zombieStateMachine.AudioThreat.distance)
                {
                    _zombieStateMachine.AudioThreat.Set(AITargetType.Audio, other, soundPos, distanceToThreat);
                }
            }
            else if (other.CompareTag("AI Food") && curType != AITargetType.Visual_Player && curType != AITargetType.Visual_Light &&
                     _zombieStateMachine.satisfaction <= 0.9f && _zombieStateMachine.AudioThreat.type == AITargetType.None)
            {
                float distanceToThreat = Vector3.Distance(other.transform.position, _zombieStateMachine.sensorPosition);

                if (distanceToThreat < _zombieStateMachine.VisualThreat.distance)
                {
                    RaycastHit hitInfo;
                    if (ColliderIsVisible(other, out hitInfo, _visualLayerMask))
                    {
                        _zombieStateMachine.VisualThreat.Set(AITargetType.Visual_Food, other, other.transform.position, distanceToThreat);
                    }
                }
            }
        }
    }
コード例 #9
0
ファイル: AIZombieState.cs プロジェクト: m-g-p/dead_earth
    // -------------------------------------------------------------------------------------
    // Name	:	OnTriggerEvent
    // Desc	:	Called by the parent state machine when threats enter/stay/exit the zombie's
    //			sensor trigger, This will be any colliders assigned to the Visual or Audio
    //			Aggravator layers or the player.
    //			It examines the threat and stored it in the parent machine Visual or Audio
    //			threat members if found to be a higher priority threat.
    // --------------------------------------------------------------------------------------
    public override void OnTriggerEvent(AITriggerEventType eventType, Collider other)
    {
        // If we don't have a parent state machine then bail
        if (_zombieStateMachine == null)
        {
            return;
        }

        // We are not interested in exit events so only step in and process if its an
        // enter or stay.
        if (eventType != AITriggerEventType.Exit)
        {
            // What is the type of the current visual threat we have stored
            AITargetType curType = _zombieStateMachine.VisualThreat.type;

            // Is the collider that has entered our sensor a player
            if (other.CompareTag("Player"))
            {
                // Get distance from the sensor origin to the collider
                float distance = Vector3.Distance(_zombieStateMachine.sensorPosition, other.transform.position);

                // If the currently stored threat is not a player or if this player is closer than a player
                // previously stored as the visual threat...this could be more important
                if (curType != AITargetType.Visual_Player ||
                    (curType == AITargetType.Visual_Player && distance < _zombieStateMachine.VisualThreat.distance))
                {
                    // Is the collider within our view cone and do we have line or sight
                    RaycastHit hitInfo;
                    if (ColliderIsVisible(other, out hitInfo, _playerLayerMask))
                    {
                        // Yep...it's close and in our FOV and we have line of sight so store as the current most dangerous threat
                        _zombieStateMachine.VisualThreat.Set(AITargetType.Visual_Player, other, other.transform.position, distance);
                    }
                }
            }
            else
            if (other.CompareTag("Flash Light") && curType != AITargetType.Visual_Player)
            {
                BoxCollider flashLightTrigger = (BoxCollider)other;
                float       distanceToThreat  = Vector3.Distance(_zombieStateMachine.sensorPosition, flashLightTrigger.transform.position);
                float       zSize             = flashLightTrigger.size.z * flashLightTrigger.transform.lossyScale.z;
                float       aggrFactor        = distanceToThreat / zSize;
                if (aggrFactor <= _zombieStateMachine.sight && aggrFactor <= _zombieStateMachine.intelligence)
                {
                    _zombieStateMachine.VisualThreat.Set(AITargetType.Visual_Light, other, other.transform.position, distanceToThreat);
                }
            }
            else
            if (other.CompareTag("AI Sound Emitter"))
            {
                SphereCollider soundTrigger = (SphereCollider)other;
                if (soundTrigger == null)
                {
                    return;
                }

                // Get the position of the Agent Sensor
                Vector3 agentSensorPosition = _zombieStateMachine.sensorPosition;

                Vector3 soundPos;
                float   soundRadius;
                AIState.ConvertSphereColliderToWorldSpace(soundTrigger, out soundPos, out soundRadius);

                // How far inside the sound's radius are we
                float distanceToThreat = (soundPos - agentSensorPosition).magnitude;

                // Calculate a distance factor such that it is 1.0 when at sound radius 0 when at center
                float distanceFactor = (distanceToThreat / soundRadius);

                // Bias the factor based on hearing ability of Agent.
                distanceFactor += distanceFactor * (1.0f - _zombieStateMachine.hearing);

                // Too far away
                if (distanceFactor > 1.0f)
                {
                    return;
                }

                // if We can hear it and is it closer then what we previously have stored
                if (distanceToThreat < _zombieStateMachine.AudioThreat.distance)
                {
                    // Most dangerous Audio Threat so far
                    _zombieStateMachine.AudioThreat.Set(AITargetType.Audio, other, soundPos, distanceToThreat);
                }
            }
            else
            // Register the closest visual threat
            if (other.CompareTag("AI Food") && curType != AITargetType.Visual_Player && curType != AITargetType.Visual_Light &&
                _zombieStateMachine.satisfaction <= 0.9f && _zombieStateMachine.AudioThreat.type == AITargetType.None)
            {
                // How far away is the threat from us
                float distanceToThreat = Vector3.Distance(other.transform.position, _zombieStateMachine.sensorPosition);

                // Is this smaller then anything we have previous stored
                if (distanceToThreat < _zombieStateMachine.VisualThreat.distance)
                {
                    // If so then check that it is in our FOV and it is within the range of this
                    // AIs sight
                    RaycastHit hitInfo;
                    if (ColliderIsVisible(other, out hitInfo, _visualLayerMask))
                    {
                        // Yep this is our most appealing target so far
                        _zombieStateMachine.VisualThreat.Set(AITargetType.Visual_Food, other, other.transform.position, distanceToThreat);
                    }
                }
            }
        }
    }
コード例 #10
0
    /// <summary>
    /// Called by the parent state machine threats enter/stay/exit the zombie`s sensor trigger.
    /// Examines the threat and stores it in the parent machine Visual or Audio threat members,
    /// if found to be the a higher priority threat
    /// </summary>
    public override void OnTriggerEvent(AITriggerEventType eventType, Collider other)
    {
        if (zombieStateMachine == null)
        {
            return;
        }

        if (eventType != AITriggerEventType.Exit)
        {
            AITargetType currentType = zombieStateMachine.visualThreat.Type;

            if (other.CompareTag("Player"))
            {
                float distance = Vector3.Distance(zombieStateMachine.SensorPosition, other.transform.position);

                if (currentType != AITargetType.VisualPlayer || (currentType == AITargetType.VisualPlayer &&
                                                                 (distance < zombieStateMachine.visualThreat.Distance)))
                {
                    if (ColliderIsVisible(other, out RaycastHit hitInfo, playerLayerMask))
                    {
                        zombieStateMachine.visualThreat.Set(AITargetType.VisualPlayer, other, other.transform.position, distance);
                    }
                }
            }
            else if (other.CompareTag("Flash Light") && currentType != AITargetType.VisualPlayer)
            {
                BoxCollider flashLightTrigger = (BoxCollider)other;

                float distanceToThreat  = Vector3.Distance(zombieStateMachine.SensorPosition, flashLightTrigger.transform.position);
                float zSize             = flashLightTrigger.size.z * flashLightTrigger.transform.lossyScale.z;
                float aggravationFactor = distanceToThreat / zSize;

                if (aggravationFactor <= zombieStateMachine.Sight && aggravationFactor <= zombieStateMachine.Intelligence)
                {
                    zombieStateMachine.visualThreat.Set(AITargetType.VisualLight, other, other.transform.position, distanceToThreat);
                }
            }
            else if (other.CompareTag("AI Sound Emitter"))
            {
                SphereCollider soundTrigger = (SphereCollider)other;
                if (soundTrigger == null)
                {
                    return;
                }

                Vector3 agentSensorPosition = zombieStateMachine.SensorPosition;

                Vector3 soundPos;
                float   soundRadius;

                ConvertSphereColliderToWorldSpace(soundTrigger, out soundPos, out soundRadius);

                float distanceToThreat = (soundPos - agentSensorPosition).magnitude;
                float distanceFactor   = distanceToThreat / soundRadius;

                // Bias the factor based on hearing ability of Agent
                distanceFactor += distanceToThreat * (1.0f - zombieStateMachine.Hearing);

                if (distanceFactor > 1.0f)
                {
                    return;
                }

                if (distanceToThreat < zombieStateMachine.audioThreat.Distance)
                {
                    zombieStateMachine.audioThreat.Set(AITargetType.Audio, other, soundPos, distanceToThreat);
                }
            }
            else if (other.CompareTag("AI Food") && currentType != AITargetType.VisualPlayer && currentType != AITargetType.VisualLight &&
                     zombieStateMachine.Satisfaction <= 0.9f && zombieStateMachine.audioThreat.Type == AITargetType.None)
            {
                float distanceToThreat = Vector3.Distance(other.transform.position, zombieStateMachine.SensorPosition);

                if (distanceToThreat < zombieStateMachine.visualThreat.Distance)
                {
                    RaycastHit hitInfo;

                    if (ColliderIsVisible(other, out hitInfo, visualLayerMask))
                    {
                        zombieStateMachine.visualThreat.Set(AITargetType.VisualFood, other, other.transform.position, distanceToThreat);
                    }
                }
            }
        }
    }
コード例 #11
0
 public virtual void            OnCollisionEvent(AITriggerEventType eventType, Collision other)
 {
 }
コード例 #12
0
ファイル: AIZombieState.cs プロジェクト: vizieryu/DeadEarth
    public override void OnTriggerEvent(AITriggerEventType aITriggerEventType, Collider other)
    {
        base.OnTriggerEvent(aITriggerEventType, other);

        if (aITriggerEventType != AITriggerEventType.Exit)
        {
            //1.player进入触发区。 (visual_player)
            if (other.CompareTag(Label.Tag.player))
            {
                //威胁距离
                float distanceToThreat = Vector3.Distance(_aIStateMachine.sensorPosition, other.transform.position);

                //视觉威胁不是player 或者 视觉威胁是player && 距离<distance.
                if (_aIStateMachine.VisualThreat.type != AITargetType.Visual_Player ||
                    _aIStateMachine.VisualThreat.type == AITargetType.Visual_Player && distanceToThreat < _aIStateMachine.VisualThreat.distance)
                {
                    RaycastHit hitInfo;
                    if (ColliderIsVisible(other, out hitInfo, _playerLayerMask))
                    {
                        _aIStateMachine.VisualThreat.Set(AITargetType.Visual_Player, other, other.transform.position, distanceToThreat);
                    }
                }
            }
            //2.灯光触发
            else if (other.CompareTag(Label.Tag.flash_light) && _zombieStateMachine.VisualThreat.type != AITargetType.Visual_Player)
            {
                BoxCollider flashLightTrigger = (BoxCollider)other;

                //用,比例来算.
                float distanceToThreat = Vector3.Distance(_aIStateMachine.sensorPosition, flashLightTrigger.transform.position);
                float sizeZ            = flashLightTrigger.size.z * flashLightTrigger.transform.lossyScale.z;
                float aggrFactor       = distanceToThreat / sizeZ;
                if (aggrFactor <= _zombieStateMachine.sight && aggrFactor <= _zombieStateMachine.intelligence)
                {
                    _zombieStateMachine.VisualThreat.Set(AITargetType.Visual_Light, other, other.transform.position, distanceToThreat);
                }
            }
            //3.声音传递
            else if (other.CompareTag(Label.Tag.ai_sound_emitter))
            {
                SphereCollider soundTrigger = (SphereCollider)other;
                if (soundTrigger == null)
                {
                    return;
                }

                //把soundTrigger转到世界轴.
                Vector3 soundPos;
                float   soundRadius;
                AIState.ConvertSphereColliderToWorldSpace(soundTrigger, out soundPos, out soundRadius);

                float distanceToSound = Vector3.Distance(_aIStateMachine.sensorPosition, soundPos);

                float distanceFactor = distanceToSound / soundRadius;
                //再计算,基于Agent听力能力的因素偏倚。
                distanceFactor += distanceFactor * (1.0f - _zombieStateMachine.hearing);
                //太远...
                if (distanceFactor > 1)
                {
                    return;
                }

                if (distanceToSound <= _zombieStateMachine.AudioThreat.distance)
                {
                    _zombieStateMachine.AudioThreat.Set(AITargetType.Audio, soundTrigger, soundPos, distanceToSound);
                }
            }
            //3.食物(尸体)
            else if (other.CompareTag(Label.Tag.ai_food) && curType != AITargetType.Visual_Player && curType != AITargetType.Visual_Light &&
                     _zombieStateMachine.satisfaction <= 0.9f && _zombieStateMachine.AudioThreat.type == AITargetType.None)
            {
                float distanceToFood = Vector3.Distance(other.transform.position, _zombieStateMachine.sensorPosition);

                if (distanceToFood <= _zombieStateMachine.VisualThreat.distance)
                {
                    RaycastHit hitInfo;
                    if (ColliderIsVisible(other, out hitInfo, _visualLayerMask))
                    {
                        _zombieStateMachine.VisualThreat.Set(AITargetType.Visual_Food, other, other.transform.position, distanceToFood);
                    }
                }
            }
        }
    }
コード例 #13
0
    //Esamina la minaccia e la salva nella "Parent Machine" se la minaccia visiva o uditiva
    //che è stata trovata ha una priorità più alta
    public override void OnTriggerEvent(AITriggerEventType eventType, Collider other)
    {
        if (_zombieStateMachine == null)
        {
            return;
        }

        if (eventType != AITriggerEventType.Exit)
        {
            //Prendo il tipo dell'attuale minaccia visiva che ho salvato
            AITargetType curType = _zombieStateMachine.VisualThreat.type;

            //Controllo che il collider entrato nel Sensor sia un Player
            if (other.CompareTag("Player"))
            {
                //Calcolo la distanza tra il sensor e il collider
                float distance = Vector3.Distance(_zombieStateMachine.sensorPosition, other.transform.position);

                //Se l'ultima minaccia salvata non è un Player o se questo player è più vicino rispetto
                //al player salvato come minaccia visiva cambio l'ordine di priorità
                if (curType != AITargetType.Visual_Player ||
                    (curType == AITargetType.Visual_Player && distance < _zombieStateMachine.VisualThreat.distance))
                {
                    RaycastHit hitInfo;
                    if (ColliderIsVisible(other, out hitInfo, _playerLayerMask))
                    {
                        _zombieStateMachine.VisualThreat.Set(AITargetType.Visual_Player, other, other.transform.position, distance);
                    }
                }
            }
            else if (other.CompareTag("Flashlight") && curType != AITargetType.Visual_Player)
            {
                BoxCollider flashLightTrigger = (BoxCollider)other;
                float       distanceToThreat  = Vector3.Distance(_zombieStateMachine.sensorPosition, flashLightTrigger.transform.position);
                float       zSize             = flashLightTrigger.size.z * flashLightTrigger.transform.lossyScale.z;
                float       aggrFactor        = distanceToThreat / zSize;

                if (aggrFactor <= _zombieStateMachine.sight && aggrFactor <= _zombieStateMachine.intelligence)
                {
                    _zombieStateMachine.VisualThreat.Set(AITargetType.Visual_Light, other, other.transform.position, distanceToThreat);
                }
            }
            else if (other.CompareTag("AI Sound Emitter"))
            {
                SphereCollider soundTrigger = (SphereCollider)other;
                if (soundTrigger == null)
                {
                    return;
                }

                //Prendo la posizione dell'Agent Sensor
                Vector3 agentSensorPosition = _zombieStateMachine.sensorPosition;

                Vector3 soundPos;
                float   soundRadius;
                AIState.ConvertSphereColliderToWorldSpace(soundTrigger, out soundPos, out soundRadius);

                //Calcolo QUANTO siamo nel raggio sonoro
                float distanceToThreat = (soundPos - agentSensorPosition).magnitude;


                //Calcolo un fattore distanza che corrisponde a 1 quando è al limite del raggio sonoro ,
                //0 quando è al centro
                float distanceFactor = (distanceToThreat / soundRadius);

                //Calcolo il distanceFactor in base alla capacità uditiva dell'Agent
                distanceFactor += distanceFactor * (1.0f - _zombieStateMachine.hearing);

                //Controllo se è troppo distante
                if (distanceFactor > 1.0f)
                {
                    return;
                }

                //Se la sorgente è udibile e più vicina rispetto a l'ultima che è stata salvata
                if (distanceToThreat < _zombieStateMachine.AudioThreat.distance)
                {
                    //Setto la sorgente più vicina
                    _zombieStateMachine.AudioThreat.Set(AITargetType.Audio, other, soundPos, distanceToThreat);
                }
            }
            else
            // Resgistro la minaccia visiva più vicina
            if (other.CompareTag("AI Food") && curType != AITargetType.Visual_Player &&
                curType != AITargetType.Visual_Light &&
                _zombieStateMachine.satisfaction <= minSatisfaction &&
                _zombieStateMachine.AudioThreat.type == AITargetType.None)
            {
                //Calcolo quanto è distante la minaccia
                float distanteToThreat = Vector3.Distance(other.transform.position, _zombieStateMachine.sensorPosition);

                //Controllo se la distanza è minore di qualsiasi copsa sia stata salvata in prcedenza
                if (distanteToThreat < _zombieStateMachine.VisualThreat.distance)
                {
                    //Se sì controllo che sia interna al FOV e al relativo range del raggio visivo
                    RaycastHit hitInfo;
                    if (ColliderIsVisible(other, out hitInfo, _visualLayerMask))
                    {
                        //Setto il target più vicino
                        _zombieStateMachine.VisualThreat.Set(AITargetType.Visual_Food, other, other.transform.position, distanteToThreat);
                    }
                }
            }
        }
    }
コード例 #14
0
    public override void OnTriggerEvent(AITriggerEventType eventType, Collider other)
    {
        if (_zombieStateMachine == null)
        {
            return;
        }

        if (eventType != AITriggerEventType.EXIT)
        {
            AITargetType curType = _stateMachine.visualThreat.type;

            if (other.CompareTag("Player"))
            {
                float distance = Vector3.Distance(_zombieStateMachine.sensorPosition, other.transform.position);
                if (curType != AITargetType.VISUAL_PLAYER || (curType == AITargetType.VISUAL_PLAYER && distance < _zombieStateMachine.visualThreat.distance))
                {
                    RaycastHit hitInfo;

                    if (ColliderIsVisable(other, out hitInfo, _playerLayerMask))
                    {
                        //its close and in our FOV
                        _zombieStateMachine.visualThreat.Set(AITargetType.VISUAL_PLAYER, other, other.transform.position, distance);
                    }
                }
            }
            else if (other.CompareTag("Flash Light") && curType != AITargetType.VISUAL_PLAYER)
            {
                BoxCollider flashLightTrigger = (BoxCollider)other;
                float       distanceToThreat  = Vector3.Distance(_zombieStateMachine.sensorPosition, flashLightTrigger.transform.position);
                float       zSize             = flashLightTrigger.size.z * flashLightTrigger.transform.lossyScale.z;
                float       aggrFactor        = distanceToThreat / zSize;
                if (aggrFactor <= _zombieStateMachine.sight && aggrFactor <= _zombieStateMachine.intelligence)
                {
                    _zombieStateMachine.visualThreat.Set(AITargetType.VISUAL_LIGHT, other, other.transform.position, distanceToThreat);
                }
            }
            else
            if (other.CompareTag("AI Sound Emitter"))
            {
                SphereCollider soundTrigger = (SphereCollider)other;
                if (soundTrigger == null)
                {
                    return;
                }

                //Get the position of the Agent Sensor
                Vector3 agentSensorPosition = _zombieStateMachine.sensorPosition;

                Vector3 soundPos;
                float   soundRadius;
                AIState.ConvertSphereColliderToWorldSpace(soundTrigger, out soundPos, out soundRadius);

                //How far inside the sounds radius are we
                float distanceToThreat = (soundPos - agentSensorPosition).magnitude;

                //calculates distance factor 1 when at edge 0 at centre
                float distanceFactor = (distanceToThreat / soundRadius);

                //bias the factor based on hearing ability of agent
                distanceFactor += distanceFactor * (1.0f - _zombieStateMachine.hearing);

                //Too Far away
                if (distanceFactor > 1.0f)
                {
                    return;
                }

                //TODO issue is here
                //if we can hear it and it is closer than what we previously have stored
                if (distanceToThreat < _zombieStateMachine.audioThreat.distance)
                {
                    //Most dangerous threat so far
                    _zombieStateMachine.audioThreat.Set(AITargetType.AUDIO, other, soundPos, distanceToThreat);
                }
            }
            else
            if (other.CompareTag("AI Food") && curType != AITargetType.VISUAL_PLAYER && curType != AITargetType.VISUAL_LIGHT && _zombieStateMachine.satisfaction <= 0.9f && _zombieStateMachine.audioThreat.type == AITargetType.NONE)
            {
                float distanceToThreat = Vector3.Distance(other.transform.position, _zombieStateMachine.sensorPosition);

                if (distanceToThreat < _zombieStateMachine.visualThreat.distance)
                {
                    RaycastHit hitInfo;
                    if (ColliderIsVisable(other, out hitInfo, _visualLayerMask))
                    {
                        _zombieStateMachine.visualThreat.Set(AITargetType.VISUAL_FOOD, other, other.transform.position, distanceToThreat);
                    }
                }
            }
        }
    }