Can't have Entities.ForEach with a job dependency?

.Schedule and .ScheduleParallel have an optional JobHandle parameter, but trying to schedule a ForEach after an arbitrary job gives an error clusterfluck.

InvalidOperationException: The previously scheduled job DetectIdleAgentSystem:smile:etectIdleAgentJob writes to the NativeArray DetectIdleAgentJob.needsPath. You must call JobHandle.Complete() on the job DetectIdleAgentSystem:smile:etectIdleAgentJob, before you can write to the NativeArray safely.

Only calling .Complete() on the job and scheduling without a dependency makes ForEach to work

For each Utomati ally takes dependency.
You can optionally pas it into schedule, and return it from the job.

You need to look at your Native Array DetectIdleAgentJob.needsPath.
You probably write in and read in another job. Or something similar.

Yeah, okay, the secret was if you pass a dependency in, you need to re-assign this.Dependency from the return. My bad

1 Like