SanderMertens / flecs

A fast entity component system (ECS) for C & C++

Home Page:https://www.flecs.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: how to use e.modified() in a query?

nneesshh opened this issue · comments

I build a query and iterate the components with each method,
in the each method call back, I update the entity component data and cal "e.modifiyed()",

but it raise an assert because "ecs_table_lock" with the query. How to solve this?

The assert is protection against accidentally changing the contents the iterator is iterating over. The fix is to defer the operations, which you can do like this:

world.defer_begin();
q.each( ... );
world.defer_end();