Quick answer: The Baker is not adding the tag during authoring. Verify with the Entity Debugger (Window > Entities > Entity Debugger) that entities actually have the tag component. A Baker must explicitly call AddComponent<YourTag>(entity).

Here is how to fix Unity DOTS entity query missing tag component. You have a PlayerTag empty struct. You author a GameObject with a MonoBehaviour that should get baked into an entity with PlayerTag attached. You query [WithAll<PlayerTag>] in a system. Zero entities match. The tag exists, the query compiles, the system runs — but nothing has the tag. DOTS authoring has several places where a tag can get lost.

The Symptom

An EntityQuery with a tag component in its WithAll or WithAny clause returns zero entities. You confirm entities exist for the expected objects. You confirm the tag struct compiles. But no entities actually have the tag. Systems that depend on tagged entities never run their logic.

What Causes This

Baker does not add the tag. The MonoBehaviour-based authoring component defines what entity is created, but the Baker translates the authoring data into entity components. If the Baker does not explicitly call AddComponent<PlayerTag>(entity), the entity has no tag.

Tag struct in wrong assembly. DOTS uses assembly reflection to find component types. A tag struct in an asmdef that is not referenced by your Baker’s asmdef cannot be added. The Baker compiles but does not link the tag.

Empty struct declaration wrong. A tag is public struct PlayerTag : IComponentData {}. Missing IComponentData implementation makes it just a plain struct, not a component. Unity does not treat it as a component and queries ignore it.

Enableable components confusion. An IEnableableComponent can be present but disabled. A query with [WithAll<MyTag>] where MyTag is enableable and currently disabled skips those entities. Use SystemAPI.HasEnabledComponent or query with explicit enabled state.

Subscene not baked. If your entities live in a subscene that has not been baked (editor just opened, subscene recently edited), the entities may not exist yet. Check Entity Debugger’s World dropdown for the right world.

The Fix

Step 1: Define the tag correctly.

using Unity.Entities;

public struct PlayerTag : IComponentData { }
public struct EnemyTag : IComponentData { }

Empty struct + IComponentData is the canonical tag. Zero-size, no runtime cost beyond existing in the entity’s chunk signature.

Step 2: Write the Baker to add the tag.

using Unity.Entities;
using UnityEngine;

public class PlayerAuthoring : MonoBehaviour
{
    public float Speed = 5f;
}

public class PlayerBaker : Baker<PlayerAuthoring>
{
    public override void Bake(PlayerAuthoring authoring)
    {
        Entity entity = GetEntity(TransformUsageFlags.Dynamic);

        AddComponent<PlayerTag>(entity);
        AddComponent(entity, new MoveSpeed { Value = authoring.Speed });
    }
}

Every tag or component you want on the baked entity must be explicitly added in Bake(). Data components take a value; zero-size tags take no second argument.

Step 3: Verify in Entity Debugger. Window > Entities > Hierarchy (or Entity Debugger in older versions). Select a GameObject’s corresponding entity in the Entities Hierarchy. Inspector shows all components on that entity.

If PlayerTag is not listed, the Baker did not add it. Re-check Bake code. If PlayerTag is listed, queries targeting it should match.

Step 4: Write the query correctly.

using Unity.Entities;
using Unity.Burst;

[BurstCompile]
public partial struct PlayerMoveSystem : ISystem
{
    public void OnUpdate(ref SystemState state)
    {
        foreach (var (transform, speed) in
            SystemAPI.Query<RefRW<LocalTransform>, RefRO<MoveSpeed>>()
                .WithAll<PlayerTag>())
        {
            transform.ValueRW.Position += new float3(0, 0, speed.ValueRO.Value);
        }
    }
}

.WithAll<PlayerTag>() filters to entities that have PlayerTag. Combined with Query<T> which itself filters by type, you get only Player entities.

Enableable Components

For runtime-toggleable tags, use IEnableableComponent:

public struct IsAttacking : IComponentData, IEnableableComponent { }

// In a system:
SystemAPI.SetComponentEnabled<IsAttacking>(entity, true);

// Query respects enabled state by default
foreach (var e in SystemAPI.Query<...>().WithAll<IsAttacking>())
{
    // only entities with IsAttacking enabled
}

Enableable components are fast to toggle (no archetype change) and great for “is currently doing X” states.

Debugging Entity State

If queries return zero unexpectedly, log entity counts:

public void OnUpdate(ref SystemState state)
{
    int total = SystemAPI.QueryBuilder().WithAll<PlayerTag>().Build().CalculateEntityCount();
    Debug.Log($"Player entities: {total}");
}

Log once on first update. If it prints 0, the tag is missing. If it prints >0 but your logic does not run, the query inside your foreach is further restrictive.

“DOTS is strict. Every tag must be explicitly added in a Baker. The ECS is honest — if it says zero, there are zero.”

Related Issues

For Burst compilation issues, see Burst Compile Error Managed Code. For general query issues, DOTS Entity Query Returning Empty covers related diagnostic patterns.

Bake adds the tag. Entity Debugger confirms it. Query finds it. Three steps, reliable ECS.