If the player fires his firearm within a certain hearing range of an Enemy Bot, the Enemy AI should be alerted to his position. My initial solution to the problem was the following: Everytime the player fires a shot, find all Enemy AI Game Objects and trigger a function that checks wether the player is within hearing range or not.
The problem is some weapons have a firerate of up to 20 shots per second. And if there are 25 enemies in the scene it means that, while shooting, I will be asking for
GameObject.FindGameObjectsWithTag(Enemy); and accessing a function within 500 times every second. This is not very performance friendly.
I cannot think of a better way to do this. Is there?