AstarPath.active.Scan() doesnt seem to work

I’m proceudrally generating a level. After I generate my map. I would call the Scan function by doing the following code:

AstarPath.active.Scan();

It works on the first iteration. I have a feature where if I press the F2 button, it will regenerate the map. After I regenerate the map, I will call the Scan function again. But it doesn’t work. There are different color tiles (which indicates that the 2 area are not connected) but there I found that there is a path from 1 side of the color tile to the other. I have to manually click on the Scan button on the Inspector, then it will rescan it and this time it will render the 2 area as 1 color.

Not sure what might be causing the issue. Is it because I am calling the Scan function immediatley after generating my map?

Hi

Try waiting in your code for a few frames. It might be the case that not all scripts or colliders have initialized themselves.
If that doesn’t work, a screenshot would be nice.

1 Like