UpdateGraphs not being called at all?

I’ve been experimenting with this pathfinding project for some time now and decided to integrate into my own project (3D URP).

In the project, I am using a grid graph. I can instantiate objects on runtime, rotate them and destroy them. All of the objects are using box colliders on them and are structured as: Parent Game Object → Actual Model with a Box Collider.

The terrain is procedurally generated but not infinite. I connected A* Pathfinder script and added a Scan call when the game runs. I had to add a delay of 1f for it to pickup all the obstacles btw (I Used simple Invoke() method for this).

Then I started testing with instantiations of objects during runtime and updating parts of the graph based on the bounds of newly instantiated objects. Here’s the code that is supposed to scan the parts of the graph based on the bounds passed:

public void ScanPartOfGraph(Bounds bounds) {
        var guo = new GraphUpdateObject(bounds);
        guo.updatePhysics = true;

And here’s how its being called in another script:

 Bounds bounds = objPrefab.transform.GetChild(0).GetComponent<Collider>().bounds;

This doesn’t work at all. It is not re-scanning the graph based on the bounds, not updating anything. I tried delaying this with coroutines, Invokes, even with loops, for 5-10-15 seconds yet no success.

What am I missing? Really could use another pair of eyes for this.

Also sharing the settings I have on the Pathfinder component.



Are you sure the bounds that you provide are correct?

Hm, I think so yes. Because when I do the manual scan via the interface, it scans the newly placed objects perfectly. Every time.

My only thought was that it didn’t pickup the newly created collider, so it needs some delay before running UpdateGraphs, but could be wrong.

Worth noting: I also tried systematically to call Scan() method after placing down the object. Just to see what happens when I scan the whole graph via code after placing down an object. Turns out, it detects the newly placed object, and it’s collider, but the nodes it makes unwalkable are in a shape of a dome (?) See screenshot.

After scanning Manually via UI:

Sample of what bounds returns: Center: (2.50, 0.00, 2.40), Extents: (0.00, 0.00, 0.00).

Could be a whole separate issue and anyways, I wouldn’t be scanning the whole graph again after placing down the object.

That’s a completely empty bounding box.
You may have to call Physics.SyncTransforms before reading the bounding box.

1 Like

Thanks for the fast replies Aron! Will try running this. Ill update the discussion.


No luck with SyncTransforms. I even tried getting the bounding box by attaching a new script to the instantiated object and then getting it after 5-10 seconds. The bounding box did return correctly, with the actual correct values, yet the graph was not updating anything. :thinking: :exploding_head:

I tried logging guo.stage, noticed that its now constantly in Pending. Earlier, when I had empty bounding box, I believe it was only Created. Pending doesn’t change to further stages.

That’s odd. Can you replicate this in any example scenes?

1 Like


To answer your question, no. I was unable to reproduce this in the provided examples.

After a whole day of brainstorming and trying different things, the issue was in the end the Physics.SyncTransforms() method call, partially. The tricky part? Finding a suitable spot to call it. Aside of that, I also had to put a delay of 2f (1f could work as well) on UpdateGraphs() method. When I combined these two additions, it worked, like a charm. Perfectly. I’ve spent 2 days on this but I felt so relieved now to see it working.

For anybody else, in the future, that comes across this issue, please (triple please) make sure you:

  • Have a proper bounding box on your object, ensure that its not degenerated.
  • Call a Physics.SyncTransforms() after instantiating your objects but before getting their bounds.
  • Optional: Put a delay on UpdateGraphs(guo, delay) method of few seconds. - This also fixes the “dome” like unwalkable nodes as seen on above screenshots.

Thanks for the fast replies Aron! This project is a life saver to many!

1 Like