I am making a Clash of Clans like game and have ran into this issue regarding walls. My AI works as follows:
- Upon spawning, it will get the closest building of a certain type (Enum Class) and pick that as its target if it has available attacking spaces around it (represented by Collision Spheres)
- AI will proceed to move to that location and attack the Building
I am using a Navigation Mesh and the AI Move To node in a Behavior Tree for this. Now the issue I am running into is when creating walls that should prevent the AI from going through them. I’m struggling to find a way to solve edge cases like this for example:
In this example, AI should not attack any of the first row walls as it isn’t necessary but should attack the second row.
My logic was to do something like this:
- AI moves to its desired location
- If the AI’s custom Collison Box Component overlaps with any wall → pick that wall as your target
- Wall dies → find closest building that you would like to attack
However, this runs into multiple problems like in the picture above, if an AI touches the first row it will attack it instantly. I am attacking with a lot of units and using RVO avoidance so using blocking volumes on the Nav Mesh is not an option as this would not cover all edge cases and would go terribly wrong somewhere (different unit counts, layouts etc…).