Skip to content

Add and Remove Component from Entity

Andrea Catania edited this page Jun 8, 2021 · 1 revision

You can add or remove Components directly from a System using the Storage<ComponentName>.

/// Add the Winner component to the Red team
void my_system(Query<EntityID, RedTeam> &p_query, Storage<Winner> *p_winners_storage) {
	for (auto [entity, red_team] : p_query) {
		p_winners_storage->insert(entity, Winner());
	}
}

However, when you don't know the exact component to add or remove when you write your system, you can use a Spawner

Clone this wiki locally