I keep having to manually scan the graphs

Using Unity 2020.3.9f1

Every time I go into play mode on Unity, I seem to lose my scans of all my graphs and have to go to my A* object and hit Scan again, then it takes a few seconds and scans them in properly.

The graphs then work fine for the remainder of play mode, but after going back to edit mode, I once again lose my scans of the graphs.

Any idea what the problem could be here?

Hi

What are your editor settings -> enter play mode options?
Do you have A* inspector -> settings -> scan on awake enabled?

Hi! So I just checked the settings and it looks like they are where I would think they need to be. Here are my settings:

1

So I was able to find a workaround to this.

I made a new script that simply calls AstarPath.Scan(); in the Start method.

I have an idea of what the problem might be but I don’t know if there is a better solution than what I did.

I’m loading my Unity scenes asynchronously, so I have 1 persistent scene with the Pathfinder script, and my graphs.

Then I have multiple other scenes with all the objects that my graphs need to read.

So I’m guessing that before, the Pathfinder was just Scanning before those scenes had fully loaded in.

I now turned off “Scan on Awake” and am scanning on Start via that other script and it is working as I intended.

Not sure if there are tips and tricks on using Astar with a multiple scene layout like this. At least it’s working well now haha

Ah, yes, that would cause issues. If the scene is not loaded when the graphs are scanned, then the graphs will just be empty.

Scanning from a script once the scenes have been loaded is the right approach in this case.

1 Like