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;
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;
guo.setTag = GameManager.NavMeshNotWalkableTag;
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.
Sorry for the late reply. I’ve been sick these last few weeks.
Yeah, point graphs are very unstructured which make them extremely hard to update in a performant way. If your points are arranged in a grid anyway, I would strongly recommend that you use the grid graph.