Untitled Project Part 10 - AI improvements (Patreon)
Content
Hope you had a Happy Thanksgiving. Recently I added the ability for the AI to take cover. This can be a complex topic but I found a simple solution.
First, defining our goal, what is taking cover?

Taking cover is simply finding the best place for you to hide behind, preferably close to you. Additionally, you are trying to hide yourself from being seen by a certain point. With this in mind I began by casting rays from the target that the AI is trying to hide from. In this case, a white sphere:

The rays extend out in an almost 180 degree fashion so that the places to search for are only nearby and never behind the shooter, as that wouldn't make much sense.

The idea is that for every ray cast, check if it hits a wall and then keep raycasting past the wall to check for the width of the wall. Then when an appropriate wall has been found, throw more raycasts from that location to ensure you can't be seen. The results were very good and by itself it is a fun hide and seek test:

I also started hooking up firing and reloading to the AI as well as the new taking cover behaviors. Here is a semi complete test. The camera and character is operated entirely by the AI:

So now the AI will be able to shoot while taking cover! Smart!
Stay tuned!
Files
Previews only