#Conflicts with `ExportPhysicsWorld:CheckDynamicBodyIntegrity` system

1 messages · Page 1 of 1 (latest)

wheat mulch
#

I recently reinstalled my OS and all the software on it including Unity 2022.3 LTS. Before I did that this script worked fine:

using Unity.Burst;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;

namespace PlayerController {
    [UpdateInGroup(typeof(TransformSystemGroup), OrderLast = true)]
    public partial struct UpdatePlayerController : ISystem {
        [BurstCompile]
        public void OnUpdate(ref SystemState state) {
            float deltaTime = SystemAPI.Time.DeltaTime;
            
            new UpdateControllerJob {
                DeltaTime = deltaTime
            }.Run();
            new UpdatePivotJob {
                DeltaTime = deltaTime
            }.Run();
            new UpdateOffsetJob {
                DeltaTime = deltaTime
            }.Run();
        }
        
        [BurstCompile]
        private partial struct UpdateControllerJob : IJobEntity {
            public float DeltaTime;

            private void Execute(ControllerAspect controller) {
                controller.Location += math.mul(controller.Orientation, controller.Movement) * DeltaTime;
                controller.Transform = controller.Transform.RotateY(controller.Rotation * DeltaTime);
            }
        }
        
        [BurstCompile]
        private partial struct UpdatePivotJob : IJobEntity {
            public float DeltaTime;

            private void Execute(PivotAspect pivot) {
                pivot.Transform = pivot.Transform.RotateX(pivot.Rotation * DeltaTime);
                float3 currentRotation = pivot.EulerOrientation;
                currentRotation.x = math.clamp(currentRotation.x, pivot.Clamp.x, pivot.Clamp.y);
                pivot.EulerOrientation = currentRotation;
            }
        }
        
        [BurstCompile]
        private partial struct UpdateOffsetJob : IJobEntity {
            public float DeltaTime;

            private void Execute(OffsetAspect offset) {
                float3 currentLocation = offset.Location;
                currentLocation.z += offset.Movement * DeltaTime;
                currentLocation.z = math.clamp(currentLocation.z, offset.Clamp.x, offset.Clamp.y);
                offset.Location = currentLocation;
            }
        }
    }
}

But after my script using any of the jobs causes an error in relation to ExportPhysicsWorld:CheckDynamicBodyIntegrity . It states that they both access the local transforms of the objects, obviously an issue but isn't the whole point of the ECS packages to handle all that for you? I am not sure what the fix is, or why it only started being an issue after I reinstalled Unity but I'd appreciate any insight on what the fix is and some explanation what the issue is specifically so that I can solve it in the future. Thanks

Edit: I realised I never put the full error in: InvalidOperationException: The previously scheduled job ExportPhysicsWorld:CheckDynamicBodyIntegrity reads from the ComponentTypeHandle<Unity.Transforms.LocalTransform> CheckDynamicBodyIntegrity.JobData.LocalTransformType. You are trying to schedule a new job UpdatePlayerController:UpdateControllerJob, which writes to the same ComponentTypeHandle<Unity.Transforms.LocalTransform> (via UpdateControllerJob.JobData.__TypeHandle.__PlayerController_ControllerAspect_RW_AspectTypeHandle.ControllerAspect__localTransformCAc). To guarantee safety, you must include ExportPhysicsWorld:CheckDynamicBodyIntegrity as a dependency of the newly scheduled job.

lucid tundra
#

when you do .Run() instead of .Schedule( your job will run immediately in main thread and will not respect any dependencies so if you want to .Run you need to call state.CompleteDependency() before your job
later you will learn some correct way to schedule your jobs and rewrite system properly