A* Pathfinding Project

RichAI / AIPath behaviour on RecastGraph update


#1

Hi,

we are using a RecastGraph for our TowerDefense game.
When the enemy cant reach the final goal, we let them walk their partial path and attack any wall (obstacle using navmesh cuts) they come close to.
When a wall is destroyed we only let the enemies targeting the wall recalculate their paths towards the final goal.

When we use RichAI all our enemies stop on any wall being destroyed. And due to our script only the enemies targeting the destroyed wall recalculate their path.
Our expected behaviour would have been that the other enemies continue to walk their previous paths unaffected by the NavMesh update.

When using AIPath we actually get the behaviour we expected, but it seems like its dropping the performance of our game.

Is there a way we can achieve that behaviour using RichAI or is there a better way in general to achieve this behaviour without sacrificing performance?


#2

Hi

When a navmesh cut updates the navmesh in any way (removed, added or moved) it will have to rebuild a whole tile in the navmesh. This will cause many nodes to be invalidated and any units that are following paths that include those nodes will have to recalculate their paths. This doesn’t happen for the AIPath script because it only follows the a list of Vector3 coordinates. The RichAI scripts relies on having access to the node data itself.

If you want the agents to keep attacking the walls I would suggest that you change their destinations to the walls when they first start attacking them.