- Home /
Detecting degrees of cover around a point?
I'm trying to develop an ai that hides from the player through waypoints placed around the map that relay information about that position to the ai which then chooses the optimum spot and goes to it. Not ground breaking I know but the parameters for selecting the optimal position are way too vague to get a smart ai. As of now it usually chooses the furthest point that isn't visible to the player. It also takes into consideration where the player is looking making waypoints behind the player better options. This is a good start for me but I would like to get a waypoint to detect the degrees of cover around the object within some close distance.
One way I was trying to do it is have raycasts emit from the object every x amount of degrees around the waypoint and if two rays next to each other hit an object it would assume the degrees between the two rays provide cover there. This obviously has accuracy issues not to mention performance issues if I ever wanted to implement dynamically changing maps. I'm dumbfounded and there isn't much discussion on how to achieve this. Is there an easier and more accurate way to do this that I'm missing?
I don't think this will get easy at any point, but you could inverse the process and look for the closest vertices of obstacles to a waypoint. If there's more than one vertex not obscured by another related to the same obstacle, it's the closest to it and providing cover along their vertices the furthest apart. Out something like that ;)
You should read this documentation on the AI from the first $$anonymous$$illzone game: http://www.cgf-ai.com/docs/straatman_remco_killzone_ai.pdf
There are several ways to do this. First thing you could do is have several THREADS and COROUTINES running in the background that do these heavy calculations so that they are ready when an AI requests it. This could take some time, but it wouldn't take much performance, and you can easily check
To how you would calculate it would be something like you said, or again you should check the killzone docs. If you have a sortof linear level design, where covers are only facing 4 or 8 directions, you would only need to check every 90 or 45 degrees. Or you could use spherecasts.