Pause in updategraph

Hi there,
Got a grid graph covering the whole of my map, its about 600x600.

When a player constructs a building, it uses the following script to update the grid graph
AstarPath.active.UpdateGraphs (building.collider.bounds);

This works absolutely fine except there’s a momentary pause of about 800ms.
Now that might not sound like much but its enough to interrupt play.

Any ideas or setting adjustments I could make to reduce this pause time?

Currently the size of each node is 2, my other option I did conciser is making it 4, but that would mean I would need to remake all my buildings again at a larger size which doesn’t seem very appealing.

Hope you can help,

Cheers
Rob

Hi

The large delay is due to a floodfill being required to calculate the different areas of the graph. However there is an optimization you can do if you are sure that a building will never divide the graph into two separate areas which cannot be reached from each other.

http://arongranberg.com/astar/docs/class_pathfinding_1_1_graph_update_object.php#a2efbcd7b73c47dce7781034f38b35da6

GraphUpdateObject guo = new GraphUpdateObject (building.collider.bounds); guo.requiresFloodFill = false; AstarPath.active.UpdateGraphs (guo);

Of course it is not certain that you can do this optimizations because of the above reason, but if you can, it is a big win.

Hi,
Will give that a try tonight.

The buildings will never separate out the graphs, simply adjust where they cant walk so that they dont end up walking through walls.
However the floors on the buildings are raised a little so the graph tends to raise up at the door ways.
(as the units can walk inside the buildings.)

Cheers
Rob

Worked like a charm, thanks very much for that.
Out of interest what exactly is flood filling doing? And why don’t I want it?

Cheers
Rob

Flood filling enables the pathfinder to tell if one node is completely inaccesible from another node to avoid wasting cpu cycles. The thing is that if a path would do a search for a node it can never get to, it will end up searching the whole graph it reach and that might take quite a long time (relatively). So what the scripts do is to make an initial search and mark nodes according to some area id, so if two nodes have the same area id, they are usually reachable from each other, if they have different area ids they are definitely not reachable from each other.

If your buildings are placed in a way so that they will never divide the graph into two (or more) different regions which the AI cannot move between, then you will not need flood filling since placing a building in that way will not change any area information.

Cool that makes sense.
Because I am using the layered grid graph, it does end up putting a seperate grid on the roof of the building but no units are ever going to walk up there so hopefully should be ok.

Cheers for the help.
Rob