Unintuitive behavior of EntityQuery in System and OnUpdate

Your query should reflect what you are looking for. Instead of checking if a query returns no result, your query should return the entities that don’t have the tag component. Something like :

[UpdateInGroup(typeof(SimulationSystemGroup))]
[UpdateAfter(typeof(SpawnEntitySystem))]
public class Example : ComponentSystem
{
    private EntityQuery _query;

    protected override void OnCreate()
    {
        _query = EntityManager.CreateEntityQuery(ComponentType.Exclude<Tag>());
    }

    protected override void OnUpdate()
    {
        EntityManager.AddComponent<Tag>(_query);
    }
}
1 Like