I started recently to use Unity for creating a small fps like game. In the game i have a big map where enemies randomly spawn around and starts to chase the player using the A* pathfinding. In the map I have multiple dynamic game objects and I frequently do a graph update as following so that new obstacles are taken in account in the path. I am using Grid Graph.
Bounds bounds = new Bounds(new Vector3(258f, -0.1f, 301f), new Vector3(100, 0, 100)); AstarPath.active.UpdateGraphs(bounds);
Actually I don’t even understand exactly what the second parameter does but i assume it creates a 100x100 node graph at the given position of the first parameter?
Well it seems to work nicely and it updates the graph and the enemies can find a new path avoiding the obstacles. The problem is that the obstacles are pretty small so i have to keep the node size at 1 to get a good result in the pathfinding. With such small nodes the 100x100 graph update goes fine but if I expand it as a 1000x1000 node graph it totally kills the game. Since there seems to be a possibility to add multiple graphs at the same time I was thinking that would the next be possible. I would like to make a small more accurate graph (lets say 100x100) that would be refreshed at the point where the enemy is so it can dodge obstacles in near proximity. I would also add an other graph at the same time that has a size 1000x1000 with very sparse nodes to get the path to the player who is somewhere in the map. Is it somehow possible to separately update each graph and keep the position of the large graph that covers the whole map at a static position and update the smaller graph such that it would be on every update centered at the enemy’s position.