In this chapter, we'll learn to implement AI behaviors using the concept of a sensory system similar to what living entities have. As we discussed earlier, a character AI system needs to have awareness of its environment such as where the obstacles are, where the enemy it's looking for is, whether the enemy is visible in the player's sight, and others. The quality of AI of our NPCs completely depends on the information it can get from the environment. Based on that information, the AI characters will decide which logic to execute. If there's not enough information for the AI, our AI characters can show strange behaviors, such as choosing the wrong places to take cover, idling, looping strange actions, and not knowing what decision to make. Search for AI glitches on YouTube, and you'll find some funny behaviors of AI characters even in AAA games.
We can detect all the environment parameters and check against our predetermined values if we want. But using a proper...