-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable and enable entities #11090
Comments
|
#9797 unblocks the implementation of this for making use of bit-level IDs, a la flecs. It would need to be a follow-up PR that then modifies the ID format to include the extra disable bit in the flag portion (the high component will then be 2 bit flag, 30 bit value versus the current 1 bit flag, 31 bit value). |
If we do the built-in disabled component we would need to give the choice of storage type |
I would like that. I work on a crate where systems can be reversed. So far despawning an entity in reversible systems just add a marker component so it can be easily undone when reversing the command. I would have to ask the user to always filter on that marker. A built-in solution would be so much better. |
I would prefer this be done via merging #9797 given that it's on the horizon and more flexible than a special |
Can you explain how #9797 would be useful for this? I'm not immediately seeing the connection. |
Edit: Engine defined disabled markers is better than user defined disabled markers. See this comment. |
Gathering some of the important discussion from @maniwani on Discord into here:
|
I want to note that those Discord discussions have been about a mechanism for disabling individual components, which is kind of orthogonal / complementary to this issue's proposed
This solution described in your OP is still what I would do for disabling entities. (edit: Like, they're both useful. |
I'm merging #13120 on Monday unless someone stops me. Once that's in, I'd like to add a |
I should note that I also have a |
Why not make sure that all requests have a filter: |
Are you talking about the alternative solution described in ###Custom marker component, or default query filters? |
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
Disabled
marker 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
Component
type. 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
Disabled
marker component of their own, and then addWithout<Disabled>
to all of their systems.However:
Additional context
flecs has a
Disabled
component and aPrefab
component that work in this fashion. It also has aPrefab
component which works in the same way.The text was updated successfully, but these errors were encountered: