The Area Detection System
The purpose of this page is to explain to the reader what the Area Detection System included in the Advanced Companion AI is and how it works.
Last updated
The purpose of this page is to explain to the reader what the Area Detection System included in the Advanced Companion AI is and how it works.
Last updated
The Area Detection system is very useful to adjust the AI behavior according to the environment the player is currently navigating in. The Area Detection system fires a bunch of rays in a 360-degree radius around the player. Those rays can either be fired in a radial or squared shape. Which shape you choose is up to you and does not affect the functionality in any way.
This is a very useful feature since the projection system which is only used by the “For Run” follow method might not always work in small spaces and it would be annoying if the AI is always walking in front of you for example when in buildings because it might be blocking your way often.
When navigating your world, there will be certain situations where the Area Detection System comes in handy. Of course, what those situations are is 100% based on your project, but one of the most common would be tight spaces in your game world. For example: When moving through / inside a building, there will most likely be walls and corridors or small rooms. With Area Detection disabled, the AI (if set to "For Run" by default) will always try to walk in front of you, which can lead to annoying gameplay like the AI companion always blocking your path. On the other hand, when moving in open areas such as grassland or a not so dense forest, the AI (if set to "Follow Behind" by default) would always walk behind you, completely overriding the "For Run" follow method.
This is where the Area Detection System comes in. When the Area Detection System is enabled, it will "scan" the environment in certain time intervals and check if it is in a more open or closed space. Based on this information, the Area Detection System will then dynamically adjust the follow method used by the AI at runtime. Of course, you can change the Area Detection System settings to suit your needs. For more information about the Area Detection settings, see the "Settings Explained" section.
After being fired, each ray returns a Boolean, stating if something was hit. You can set a certain detection sensitivity (Low = 25% / Medium = 50% / Heigh = 75%). Based on the set sensitivity, the area detection system will change the AI´s follow method when activated.
Let’s say as an example, you choose radial detection, shoot 4 rays in total and set the sensitivity to 50%. If you now move inside of a building with your AI in follow mode and 2 or more of your rays hit a wall, the AI will automatically switch to the “Follow Behind” follow method.
However, you have the freedom to design this system as you want or disable it completely using the settings in the companion component of your companion AI.