Althoug sometime (1 at 20 times), the pathfinding is found in the log, but the callback in the path object ( for example OnPathfindComplet(Path ) ) is not called. So I can’t get the path found and everything is freeze.
The only 'unsusal" thing I do is I recalculate the node grid at runtime (my map is randomly generated).
I can only think of one reason.
You are using a seeker and you are requesting a path, and then before it has been returned, you request another path. That will cancel the first path, and the first path will not be returned (this is expected).
That’s not that. If a path is cancelled that way, there is a message in your log (and according to the log everything is fine).
I’m also asking a new pathfind calculation only if the last one is finished (but still force it if it takes more than 1 seconds).
I tried to debug it, but it happen rarely and each time I’m able to debug, mono crashed after a few click…
It push the path result in the queue but it’s never pop (the bebugger crash each time I try to see why).
But I still can’t let this kind of bug in a commercial game.
Hm… Maybe one of your OnPathComplete methods raised an exception. I think that could potentially cause paths to not be returned… [EDIT] Scrap that, won’t happen.
Try adding some Debug.Log calls in AstarPath.cs -> ReturnPaths method to see which paths are being returned. Logging their pathID is a nice way to separate them from each other.
I would be very helpful if you can post #1: Your scripts for this
and #2: A screen shot of your seeker
Generally I find it best to debug this kind of thing by having a Debug.log(Method name) in each method, and when I find an error like this, add more Debug.log’s in the Method until I isolate the issue.
I wanted to say that I am also experiencing this bug. What I found is that in the cases where the callback fails, the ReturnPathsHandler seems to never start. If I put some debug text in there, and it spams the console, I’m all good, if not, the callback never occurs (for seemingly obvious reasons). Any reason that coroutine might not actually trigger?
[EDIT] Actually looks like it runs one time then stops.
[EDIT2] Stranger, looks like it sometimes stops, then will randomly start up again, no clear pattern to it.
POSSIBLE FIX: Wildfactor, you might try this and see if it helps you, with some (not yet enough) testing it seems to have fixed it for me. Moving the intial call of
StartCoroutine (ReturnsPathsHandler());
to a Start() function and not having it in Awake() seems to make it reliable. Tried it based on this post: