Unity version:6.0.23f
My code is working fine but I only using it in the editor currently and multithreading problems often don’t appear regularly so are hard to debug. So I want to check if I am doing this correctly.
This is from the example in the docs. To make the AstarWorkItem run immediately do I have to do anything other than use force => { return true;}
the docs says
// In that case this method should
// block and return true when done.
I did not know if that meant it will block and run immediately if force is true or if I should do something to make it block and run immediately if I set force => { return true;}
AstarPath.active.AddWorkItem(new AstarWorkItem(() => {
// I create new nodes here
},
force => {
// Called every frame until complete.
// Signal that the work item is
// complete by returning true.
// The "force" parameter will
// be true if the work item is
// required to complete immediately.
// In that case this method should
// block and return true when done.
return true;
}));
You are misunderstanding the documentation. The return value of that second callback is true if the work item completed, and false if it still has work to do. The force parameter will be true if the work item should complete all its work immediately.
If you want to force a work item to run immediately, then use AstarPath.active.FlushWorkItems().