Re-Scanning during play-mode

In my 2D top-down game, there is only one Grid graph that I want to re-scan whenever objects are getting moved (so it’s essential to re-scan, otherwise enemies may go through objects) and I call AStarGrid.Scan() when the player stops moving objects (so I just call in once) but it’s not very smooth and the game freezes a tiny bit.

I tried ScanAsync() and the game doesn’t freeze but for some reason, it doesn’t re-scan the grid.

Have any idea how to make it not freeze the game?

Hi

Did you start ScanAsync as a coroutine? StartCoroutine(AstarPath.active.ScanAsync(...)).

If you know which objects are getting moved, you can also update just a small part of the graph. This will be much faster. See Graph Updates during Runtime - A* Pathfinding Project

1 Like

thannnnks! UpdateGraphs() works perfectly.

1 Like