#OverlapSphereCommand.ScheduleBatch() keeps crashing.

1 messages · Page 1 of 1 (latest)

delicate shuttle
#

I am getting a very inconsistent crash with very inconsistent log. (The log is never the deterministic, it crashes on other jobs, other systems, etc)
When I don't run this code, everything is fine again.

// Initialize NativeArrays
            _colliderData = new NativeArray<BulletColliderData>(_dataCount, Allocator.TempJob);
            _commandData = new NativeArray<OverlapSphereCommand>(_dataCount, Allocator.TempJob);
            _outputData = new NativeArray<ColliderHit>(_dataCount * MAX_COLLISION_HIT, Allocator.TempJob);

            // Gather Job Data
            for (int i = 0; i < _dataCount; i++)
            {
                _colliderData[i] = _dataList[i].GetColliderData();

                QueryParameters queryParameters = new QueryParameters
                {
                    hitTriggers = QueryTriggerInteraction.Collide,
                    layerMask = _unitLayerMask
                };

                _commandData[i] = new OverlapSphereCommand(_colliderData[i].Position, _colliderData[i].Radius, queryParameters);
            }

            // Schedule Job
            JobHandle jobHandle = OverlapSphereCommand.ScheduleBatch(_commandData, _outputData, 1, MAX_COLLISION_HIT);
            jobHandle.Complete();

            // Inform Collision
            for (int i = 0; i < _dataCount; i++)
            {
                for (int j = 0; j < MAX_COLLISION_HIT; j++)
                {
                    int collisionIndex = (i * MAX_COLLISION_HIT) + j;

                    ColliderHit hit = _outputData[collisionIndex];

                    if (hit.collider == null) continue;
                    
                    _dataList[i].OnCollision(hit);
                }
            }
            DisposeAllNativeArrays();
#

Amount of data is pretty low too, its only 50 bullets.

#

And sometimes I notice its obvious missing hits.

delicate shuttle
#

Nvm, its all suddenly fixed when I turned on "AutoSyncTransform" from Project Settings

#

Not sure why this causes crash when its left to false.