Support Forum

UpdateGraphs taking foverer (30 seconds or more) even if bounding box is small or no change has been done

I have a simple point graph of points arranged on a square grid.

I want to update parts of the graph when a new building is placed so I’m calling the following when I place a building.

            Bounds bounds = new Bounds(transform.position, new Vector3(2, 2, 2));
            var guo = new GraphUpdateObject(bounds);

            guo.resetPenaltyOnPhysics = false;
            AstarPath.active.UpdateGraphs(guo);

For some reason, when the building is placed it takes a very long time to finish, 30 seconds or more which is definitely not normal. It doesn’t matter what changes I do (change penalty or add point nodes), it always gets stuck at updating the graph. In fact, even if I just try to update within those bounds without changing anything it gets stuck.
What am I doing wrong?

I’m constantly updating graphs (door close/open, floor type, etc) I think your problem lies in the updatePhysics


As you can see it’s very slow:
What I constantly do is:

		bounds = GetComponent<Collider>().bounds;
		guo = new GraphUpdateObject(bounds);
		guo.modifyTag = true;
		guo.updatePhysics = false;

And then depending on the changes:

guo.setTag = GameManager.NavMeshWalkableTag;
AstarPath.active.UpdateGraphs(guo);

or

guo.setTag = GameManager.NavMeshNotWalkableTag;
AstarPath.active.UpdateGraphs(guo);

Establish your penalty on the tags, if you want it to be fast when updating graphs

Are you also using Point graph? I think it’s an issue with the point graphs specifically, because is I use a grid graph instead, the update is basically instantaneous.