I’m wondering if anyone has used a GridGraph to dynamically find cover for an AI to retreat to? Importantly, my game is top-down 2D with crouching. My non-walkable layers are Walls and Collision (knee-high). (The graph itself is generated as expected.)
Currently I have to place all of my possible cover positions manually, and as I introduce more and larger maps, this is becoming a big time sink (not to mention having to return if something changes). Basically I need to iterate each node that sits on the edge of the Collision layer (not Walls) and determine whether it’s a position to take cover in:
The above image is showing what I’m hoping to accomplish. All the nodes along the red line would be a good place to defend from the green arrows. I wonder if I could somehow use the direction to the Collision as an indicator of what directions it might protect from. I’m not sure yet how I’d ensure AI didn’t try to run to the same position, but I was hoping someone here might have some idea of how to go about gettinng started with automating all of this?
I assume it’s something I should calculate and store at Edit time, to avoid a big performance hit?
Any help is greatly appreciated!