Support Forum

Character lag when rescan and other scan questions

Hi,

I have seen a few threads like this but have yet to determine if this is the way A* works or if there is a way around this issue. I am using Beta.

If I go down the route of re-scanning my graphs (recast), this happens:

I am controlling my character (running), and within my run a NPC comes into my graph area (250x250), so I scan my in order to use A*. The issue is that my character lags for a split second while the graph is scanned, it might just be 80-120ms spike, but its very noticeable within gameplay. As far as I have read, threads will not help as the scan is done on unity’s main thread, correct?

If yes, is there a way around this and still use a scan in my situation?

I am using the following rescan code that I have found in your documentation:

		IEnumerator UpdateGraphCoroutine ()
        {
            foreach (Progress progress in AstarPath.active.ScanAsync()) {
                //Debug.Log("Scanning... " + progress.description + " - " + (progress.progress*100).ToString("0") + "%");
                yield return null;
            }
        }

I also not determine that following by reading the documentation, can you please answer:

  1. Can you use GraphUpdateScene for recasts?
  2. Does recasttileupdate, recasttileupdatehandler and GraphUpdateScene just update current scanned graph? Or can you use these to add to an existing graph?

Thanks.

did you find any solution for this?
because i cant

I did not find a solution so have dropped A* for this project.

Hi

Sorry for the super late reply.

Yes, though in your case you probably want a raw GraphUpdateObject (or just AstarPath.active.UpdateGraph(bounds)) since it’s easier to use from code.

They all update the current graph.

In the beta almost everything in the recast scan is done in a separate thread. One major thing that cannot be done in a separate thread is to collect the meshes that have to be scanned. I would recommend using colliders (enable rasterize colliders in the recast graph settings) and not meshes because colliders can be found in a more optimized way.

1 Like