# Positioning multiple graphs on graph update

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.

Hi

No, that is far from what it does.
A bounds object define an axis aligned bounding box ( see http://en.wikipedia.org/wiki/Bounding_volume ).
Also see http://docs.unity3d.com/Documentation/ScriptReference/Bounds.html

The bounds specify a center and a size. You should choose them so that it is as small as possible, but still encloses the character ( or more precisely, the region of the graph you wish to update ).

The approach you want is possible, but it is not something I would recommend.
It seems like what you want can be best accomplished using a recast graph with navmesh cutting ( see http://www.arongranberg.com/2013/08/navmesh-cutting/ ).

For a start, lower the size parameter, using a size of (100,0,100) would essentially mean that you update the whole graph every time. I don’t think you need a size larger than something like (5,0,5).

For other reasons a 1000*1000 graph might be a bit too slow anyway, but try to change the size at first and see how that goes.