Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Strange Dependancy issue when performing with collisionWorld and DisplayCollisionEvent enabled

Discussion in 'Physics for ECS' started by NT_Ninetails, Nov 22, 2021.

  1. NT_Ninetails

    NT_Ninetails

    Joined:
    Jan 21, 2018
    Posts:
    195
    so I perform some collisions tests after the EndFramePhysicsSystems. it works beautifully when the DisplayCollisionEvent is turned off but when I turn it on I get the classic

    The previously scheduled job DisplayCollisionEventsSystem: DisplayCollisionEventsJob reads from the Unity.Collections.NativeArray`1[Unity.Physics.RigidBody] DisplayCollisionEventsJob.UserJobData.World.CollisionWorld.m_Bodies. You are trying to schedule a new job [CustomSystem]:[CustomJob], which writes to the same Unity.Collections.NativeArray`1[Unity.Physics.RigidBody] (via [CustomJob].JobData.collisionWorld.m_Bodies). To guarantee safety, you must include DisplayCollisionEventsSystem: DisplayCollisionEventsJob as a dependency of the newly scheduled job.

    So I added it like so

    Code (CSharp):
    1. Entities.ForEach(()=>{
    2. ...
    3. })
    4. .Schedule(m_EndFramPhysicsSystem.GetOutputDependency());
    5. //Another thing i tried
    6. //.Schedule(JobHandle.CombineDependencies(m_EndFramPhysicsSystem.GetOutputDependency(),m_BuildPhysicsWorld.GetOutputDependency()))
    '

    But when I add that dependacy I get the following error:


    The previously scheduled job TRSToLocalToWorldSystem:TRSToLocalToWorld writes to the ComponentDataFromEntity<Unity.Transforms.LocalToWorld> TRSToLocalToWorld.JobData.LocalToWorldTypeHandle. You are trying to schedule a new job [CustomSystem]:[CustomJob], which reads from the same ComponentDataFromEntity<Unity.Transforms.LocalToWorld> (via [CustomJob].JobData.GetLTWR). To guarantee safety, you must include TRSToLocalToWorldSystem:TRSToLocalToWorld as a dependency of the newly scheduled job.

    I looked at TRSToLocalToWorld, EndFrameTRSToLocalToWorldSystem and TransformSystemGroup but there is no way to get any Dependency and the TRSToLocalToWorld uses a protected override on its onUpdate() method.

    Is this a bug or am I using the wrong dependencies?