I figured it out. Still a work in progress but the cost is now 0.24ms
void Update()
{
BatchOverlapSphere();
}
private void LateUpdate()
{
SphereHandle.Complete();
JobSphere.Dispose();
JobResults.Dispose();
}
void BatchOverlapSphere()
{
JobSphere = new NativeArray<OverlapSphereCommand>(ActiveAI.Count, Allocator.TempJob);
JobResults = new NativeArray<ColliderHit>(ActiveAI.Count * 3, Allocator.TempJob);
var layer = new QueryParameters(DefaultLayers.Player);
for (int i = 0; i < JobSphere.Length; i++)
{
JobSphere[i] = new OverlapSphereCommand(PositionAI[i].position, 10f, layer);
}
SphereHandle = OverlapSphereCommand.ScheduleBatch(JobSphere, JobResults, 1, 3);
}
@Spy-Master Next time, when explaining could you please post a code example? You have done it before.