-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Commands double (or more) despawn and NoSuchEntity Error. #487
Comments
+1 for it - dealing with double despawn panics was hardest thing while developing my own game. |
Do you have some example code that creates this issue? |
Just despawn an entity two times. |
If you despawn something twice using an entity reference, that's a bug right? After all, keeping a stale entity reference is useless. |
You may need several systems to despawn an entity for several reasons. |
Yeah at this point I think allowing double despawns feels like the right call. The alternative is synchronization across systems that might free an entity, which imo isn't worth it. This is a tough call. I cant think of any significant problems from double despawns, whereas synchronization is a significant problem. Flecs (another popular ecs) uses this approach with success. |
Would an option be to return a |
Command's methods return Command so it can be nested. |
Seconding this. Right now, I have an entity that holds a 2d array of booleans, encapsulated in a
The main problem is 1. Since it uses the It is quite annoying to keep track of which entities have been despawned. I think Bevy itself should be able to do this, and ignore any double despawns. As a quick hack I thought I'd just wrap it with UPDATE: Just tried keeping track of despawned entities by adding a |
I gave it a shot in #649 |
Right now if we despawn an Entity with Commands and by user error we despawn this Entity more than once we get the error NoSuchEntity and this error is produced by Commands internally. There is no way to cach the error by the side of the user cause despawn in Commands returns it's Self.
This error is very hard to track down. It requires to check all the calls of despawn in a project, etc.
But even doing so there are times where you want to despawn all the entities with a specific Compoment and this will lead to NoSuchEntity errors, the only sollution I was able to come up was to despawn those entities in a thread_local_system.
I believe that silencing the error internally will be a huge gain in productivity. Maybe a call to dbg! to inform the user that more than one calls of despawn to an entity where called it will be ideal too.
I do not know the overhead of all this, but a solution to this problem have to be found.
The text was updated successfully, but these errors were encountered: