EntityComponentSystemSamples
EntityComponentSystemSamples copied to clipboard
Collision Events Error InvalidOperationException: The previously scheduled job CollisionEventConversionSystem:CollectCollisionEventsJob reads from the Unity.Collections.NativeHashMap`2[Unity.Entities.Entity,System.Int32]
I copied the collision code to my project and had this when running
Error:
InvalidOperationException: The previously scheduled job CollisionEventConversionSystem:CollectCollisionEventsJob reads from the Unity.Collections.NativeHashMap`2[Unity.Entities.Entity,System.Int32] CollectCollisionEventsJob.UserJobData.PhysicsWorld.CollisionWorld.EntityBodyIndexMap. You must call JobHandle.Complete() on the job CollisionEventConversionSystem:CollectCollisionEventsJob, before you can write to the Unity.Collections.NativeHashMap`2[Unity.Entities.Entity,System.Int32] safely.
Fix
if i add to DynamicBufferCollisionEventAuthoring (unity.physics 0.50, i removed the reference to the physics world)
Dependency = collectCollisionEventsJob.Schedule(m_StepPhysicsWorld.Simulation, Dependency);
Dependency.Complete(); // added waiting for the job to finish
it works, but does hold up the game
I had this issue also with physics 0.0.8
Is there a better way to avoid the error?
I played around with forums and stackoverflow and everywhere .Schedule was without complete :(