Splitting scanning into multiple frames?

Hello, is there any builtin way of scanning a graph over time? I have a huge multilayer world, but it’s singleplayer, so I can cheat quite a bit and only have the area visible by the player as pathable. To do this, I have 2 identical graphs that are positioned where the player is most likely to move based on their movement pattern, and only one of them is used actively in pathing.

This is working fine and dandy, but in the frame where a graph is repositioned (and thus, rescanned), I get a huge lag spike (~100ms frame time) due to scanning. Is there a built-in way of spacing out the scan over multiple frames, or even better, rate limit it to a specific max time per frame? The player moves rather slowly, and there’s lot of margin to keep this seamless from a gameplay (I currently request a reposition way before the edge of the graph).

I saw some posts that indicated this feature existed at some point:

But it seems this is on a branch “rvo_fix”, and not in the master, downloadable branch. I’m on version 3.8.8.1.

(BTW, the docs for ScanLoop are wrong/outdated, it returns void, not IEnumerable)

Hi

Have you checked out the example scene called ‘Procedural’? It shows a grid graph that moves with the player in small increments and avoids recalculating nodes it doesn’t have to recalculate. To keep CPU spikes low I recommend that you only use it for small to medium sized graphs though (≈100x100).

Yes, I checked that out, but it doesn’t seem to work with _Layer_GridGraph.
That script is actually what inspired me into making this alternating graph script, because I don’t have enough knowledge of the implementation to port the procedural mover to the Layered graph (yet).

Hi

Ah.
I just released version 4 and one of the improvements in that version is that the ProceduralGridMover now has support for layered grid graphs. Version 4 is a paid upgrade however, but if you bought the package within the last 60 days you can upgrade for free. That version also contains the new ScanAsync method.

They have existed to some extent in a few beta versions, but never in a non-beta release.

Oh I see. Fortunately I bought the asset recently! Is this upgrade available directly from the update area of the settings, or do I have to request it separately?

You can download the update here: https://www.arongranberg.com/astar/download
It is still a release candidate, so it has not been released to the Unity Asset Store yet.

Not sure which area you mean by this.

Let me know if anything doesn’t work as it should.

I just meant the “update” button of the Pathfinder editor.

Thanks for the quick responses! Will test the new version when I’m back at my PC.