-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Disable and enable entities #11090
Copy link
Copy link
Closed
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-FeatureA new feature, making something new possibleA new feature, making something new possibleD-ComplexQuite challenging from either a design or technical perspective. Ask for help!Quite challenging from either a design or technical perspective. Ask for help!S-Needs-DesignThis issue requires design work to think about how it would best be accomplishedThis issue requires design work to think about how it would best be accomplishedX-BlessedHas a large architectural impact or tradeoffs, but the design has been endorsed by decision makersHas a large architectural impact or tradeoffs, but the design has been endorsed by decision makers
Milestone
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-FeatureA new feature, making something new possibleA new feature, making something new possibleD-ComplexQuite challenging from either a design or technical perspective. Ask for help!Quite challenging from either a design or technical perspective. Ask for help!S-Needs-DesignThis issue requires design work to think about how it would best be accomplishedThis issue requires design work to think about how it would best be accomplishedX-BlessedHas a large architectural impact or tradeoffs, but the design has been endorsed by decision makersHas a large architectural impact or tradeoffs, but the design has been endorsed by decision makers
What problem does this solve or what need does it fill?
For gameplay or performance reasons, it is common to want to temporarily disable entities.
While disabled, they should generally not be interacted with in any way.
What solution would you like?
Add a special
Disabledmarker component. Entities with this component do not appear in any queries, unless the query containsWith<Disabled>(or otherwise explicitly requests that component).I'm indifferent to either hard-coding a single type for this, or making this behavior an associated constant on the
Componenttype. The former is simpler, but the latter is end-user extensible and arguably more elegant.What alternative(s) have you considered?
Respawning
We could save, despawn and then respawn the entities. However it is both simpler and faster to keep the entities alive but filter them from (most) queries.
Additionally, reading the data of despawned and stored entities is much more challenging.
Custom marker component
Users could add a
Disabledmarker component of their own, and then addWithout<Disabled>to all of their systems.However:
Additional context
flecs has a
Disabledcomponent and aPrefabcomponent that work in this fashion. It also has aPrefabcomponent which works in the same way.