I am trying to scan pathfinding system. If i run Scan() all works fine. But if i use ScanAsync() it is not scanning. I am calling it in Start() btw. What should i do? I need to scan map quickly.
Hey there! I checked this out and tried it for myself- and it looks like the Async scan runs as a Coroutine (note: if this is the wrong way of explaining this, someone feel free to correct me :D). So you either need to
A) change private void Start()
to Ienumerator Start()
:
IEnumerator Start () {
foreach (Progress progress in AstarPath.active.ScanAsync()) {
Debug.Log("Scanning... " + progress.ToString());
yield return null;
}
}
or
B) in your current Start()
, start a seperate coroutine for the Async scan:
void Start(){
StartCoroutine(DoScan());
}
IEnumerator DoScan(){
foreach (Progress progress in AstarPath.active.ScanAsync()) {
Debug.Log("Scanning... " + progress.ToString());
yield return null;
}
}
By the way, as you said you need to scan the map quickly, if you’re making constant changes to the map, I’m pretty sure the DynamicGridObstacle class would help here: DynamicGridObstacle - A* Pathfinding Project
Hope this helps!
Thanks for reply! It works with ienumerator probably But I realized that I can’t use it, I need the pro version
Ah, I see , sorry about that! Definitely let us know if we can help around here with anything else though!