What are the performance implications for adding/removing tags on an entity every frame (i.e. changing archetype)? Is there a point where it’s worth set a component variable instead, and what are the factors involved (frequency, number of entities affected)?
I’ve seen this mentioned as something to consider, but nothing concrete. Is it something to consider for the average game, or only if making something like the megacity demo?
If you plan add / remove tag on same entity every frame, you are better to use variable of the component.
But if you have for example 100k entities, adding / removing tag, can reduce number of entities iterations in the system (s), by filtering relevant entities. So you don’t need iterate through all 100k, but only selected group of entities. Can be specially useful, if you don’t need change tag state every frame.
However, for few entities probably there wont be any much of differences, in which method you will choose.
Surely you won’t notice any impact.
But for 1k, 10k, 100k most likely.
I can not 100% confirm it, but I know, that empty tags are treated differently, than component with data.
How much difference is between setting / removing tag vs setting value in component, I never tested.
But both approaches can serv different needs.