Search Unity

Tags and Archetypes

Discussion in 'Entity Component System' started by turick00, Sep 11, 2020.

  1. turick00

    turick00

    Joined:
    Jul 14, 2020
    Posts:
    31
    I've seen several examples where someone adds a tag (empty component) to an entity, just do that some system can query for it to perform some basic action, at which point, the tag is removed.

    Is this concerning at all or should any care be taken, since changing an entity's components changes its archetype? Or is the cost negligable?

    Also, can you only query for the existence of components on entities, or is it possible to do value queries?
     
  2. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,264
    Value queries can be done through shared components, which also affect archetypes. Changing archetypes does have a non-negligible cost. It isn't the most expensive thing in the world, but it isn't the cheapest thing in the world either. Whether or not to do things that way depends on your use case.
     
    turick00 likes this.