EntityCommandBuffer not destroying children along with parent at sync point?

I have a system which destroys some entities depending on game logic using
EndSimulationEntityCommandBufferSystem ecb, then there is another system which runs on PresentationSystemGroup updates children of these entities depending on the parent.

The frame in which the entity is destroyed, the system which processes the children is giving “Rotation component does not exist on parent entity” error (using ComponentDataFromEntity), but if I check parent.Value is not null and there is no system that removes the Rotation component (so both parent and children is not destroyed at this point? I don’t get it).

If I use EntityManager.DestroyEntity for destroy then there is no problem.

Hope this is clear. What am I doing wrong here?

EndSimulationEntityCommandBufferSystem typically runs after TransformSystemGroup but before PresentationSystemGroup. So the TransformSystemGroup hasn’t had a chance to update components when the error occurs.

1 Like

Oh wow… Thanks for the quick reply. I moved it to BeginSimulationEntityCommandBufferSystem but then it clashes with all my other systems in there. But BeginInitializationEntityCommandBufferSystem works.