hi, i am trying to get random position in ECS job, is it possible ?
To clarify, you’re trying to do something like NavGraph.RandomPointOnSurface in ECS? I’ll have to get some help on this one (ECS is a blindspot for me at the moment) but I wanted to get a little more information if possible ![]()
Yes like that. I have some agents that wondering around. Sometimes they should get new destination In an ECS job if it’s possible
Hi
You can do this in ECS, but you cannot do it in burst. The graph data is itself is inherently managed data, so unmanaged burst code will never be able to access it.
But you can do something like this:
var readLock = AstarPath.active.LockGraphDataForReading();
var handle = new MyJob {
// ...
// Code can for example run AstarPath.active.GetNearest(...);
}.Schedule(readLock.dependency);
readLock.UnlockAfter(handle);
The locking is required because otherwise you may run into race conditions if the graph data is updated at the same time by graph updates.
2 Likes