Check if path exists in ECS

  • A* version: 5.2.5
  • Unity version: 6000.0.31f1

Hello! I am using Unity ECS to code my pathfinding and I want to regularly check whether my agents can reach certain destination. I want to do this from systems or ideally also from jobs.

In Mono classes I would simply call PathUtilities.IsPathPossible(), but I think this is not possible to call directly from ECS system or job, as this method is relying on managed components which I want to avoid as much as possible.

What should be equivalent of PathUtilities.IsPathPossible() in pure ECS environment?

Thanks in advance for your responses!

Hi

The pathfinding data is fundamentally managed. So you will not be able to use that code from burstified jobs.

However, you can definitely use it from non-burstified jobs:

pseudocode:

MyJob {
    void Execute () {
        PathUtilities.IsPathPossible(...);
    }
}

// Ensure the graphs are not updated while the job runs
var graphLock = AstarPath.LockGraphDataForReading();
var handle = new MyJob {}.Schedule();
graphLock.UnlockAfter(handle);
1 Like

Thank you! I will see what I can do then