Search Unity

Entities not being destroyed in a timely manner

Discussion in 'Entity Component System' started by Init33, Sep 28, 2019.

  1. Init33

    Init33

    Joined:
    Aug 30, 2017
    Posts:
    67
    I have a bit of an issue and I'm not sure where to look to answer the question myself. Hopefully you can help patch some of the gaps.

    Basically I have a JobComponentSystem that has a job which moves objects and a job that removes objects conditionally. When those objects reach a target they set a flag which notifies the second job (which depends on the first) that those entities need to be removed. Removing these objects is done via a concurrent command buffer that is unique to that job. I.E. I instantiate a concurrent EntityCommandBuffer, hand it to the job struct, call complete on the job and then playback the buffer.
    So on every update cycle of the job, it should move all those objects by a frame and then remove any of those objects that need to be removed.

    However in practice I find that entities aren't being destroyed immediately when I want them to. Several frames can go by before they finally disappear. I was under the impression that calling playback() on a EntityCommandBuffer would wait until all those commands had been processed before going through the JobComponentSystem OnUpdate another time. But the fact that these objects are still moving for several frames while objects which should be deleted are still sitting there visible indicates this is not the case.

    I should mention that when I step my code frame by frame I don't see this issue.

    Help me to understand what is going on here.
     
  2. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,684