I’m trying to implement a system where the AI can dynamically find paths the have cover along the way. Here’s the rough overview of how I’d like to do it.
- Generate a list of points/vector3’s that correspond to and are linked to all of the nodes on a grid graph.
- From each of those points fire a raycast from directly above the point (to match the height of the AI) towards the player to determine whether or not the position is “in cover” (this would be done continually so that the points are always up to date)
- For every point that is not in cover, the corresponding node is given a penalty.
I’m not sure how to the penalty system works or even how to assign penalties to specific nodes, so that is my first problem. Second, I’m not sure how to best create a list of points that is linked to all the nodes (not even sure how to find the list of all nodes).
There’s couple other things that I’d like to do that may complicate things. First, I’d like to keep the system as dynamic as possible. I want enemies to prioritize paths in cover differently depending on their state (for example, an enemy with low health would avoid non covered nodes more than a full health enemy). I’d also like to be able to access the list of neighbors for each node in order to find nodes that are in cover but have neighbors that are not (this is useful as it can provide positions for the ai that allow it to pop in and out of cover)
I suppose my main questions are:
How can I access a list of all the nodes (and get information such as position and neighbors)?
How do access/change the penalties for each node?
How can I dynamically adjust how expensive penalties are based on AI state?
And perhaps most importantly:
Is this even a reasonable way to go about doing this, or is there a faster/easier way?