-
-
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
commands despawn does not update childrens parent #5584
Comments
I looked a bit at this issue and here is a passing test case with grand_parent -> parent -> child hierarchy, that doubly breaks the Children/Parent relation, namely the two last asserts.
We can see that after call of
The despawn commands does not handle at all the hiearchy relation. |
I tried to write a workaround in my game: fn despawn_invalid_system(
mut commands: Commands,
world: &World,
parents: Query<(Entity, &Children)>,
) {
for (parent_entity, children) in &parents {
for &child_entity in children {
if world.get_entity(child_entity).is_none() {
commands
.entity(parent_entity)
.remove_children(&[child_entity]);
}
}
}
} But it crashes because |
I'm not sure if this issue is getting much attention, but I wanted to bump it because there's a very old PR, #386, whose title implies that the issue is fixed, and a few other issues reference that PR and also imply that the issue is fixed. However, the fix from 2020 only applies to So for anyone still getting hit by this, you can do one of two things: either (a) don't use I honestly wonder if Just my two bits, but maybe it's time to make |
This will be resolved when #12235 is closed. |
Bevy version
0.8
What you did
I making a video about the new changes to bevy's hierarchy and I found that if you despawn an entity that has children, said children will keep the now non-existent entity as their parent.
What went wrong
console to read
console to reads
I believe this should be classified as a bug because it would be unexpected for children to reference a parent that has been despawned, this also breads the ease of finding root nodes as these nodes are now free floating.
How to fix
I don't know whether
they should just be cut free to become roots themself -- easier
or if
they should be grafted up a parent if there is one to attach to if not then made free -- harder/slower
The text was updated successfully, but these errors were encountered: