Call GetNearest() in Job?

Is it possible to call GetNearest() from job, to prevent slowing down main thread?

Pro version 4.3.56

AstarPath.active.GetNearest(Position).node;

Hi

It is possible to call it from a separate thread, but you must ensure that this is not done while any graph updates are being done. So for example starting a job on multiple cores and immediately joining on it in the main thread is perfectly fine, because then you know the main thread will not go on and e.g. start running graph updates.

Hi, when are graphs updating? I want to start job (or more jobs at once) and not forcing job complete until job completed. This mean, job can run during multiple frames. Is it ok?

Hi

You will not be able to run this over multiple frames. Graphs can start updating during any Update() call. During this time, AstarPath.active.workItemsInProgress will be true. Though, of course, no graph updates will happen unless you call AstarPath.active.UpdateGraphs, AddWorkItem, Scan, add a GraphUpdateScene component, or move a DynamicGridObstacle/NavmeshCut component.