Despawn entities on relationship component removal when linked spawn is enabled
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## What problem does this solve or what need does it fill?
The following code works:
```rust
let mut world = World::new();
let mut entity = world.spawn((
Name::new("Root"),
children![Name::new("Child1"), Name::new("Child2"),],
));
entity.remove::();
assert_eq!(world.entities().len(), 3);
```
But I'm not sure if this behavior is expected/desired. This makes it easy for users to "leak" entities.
## What solution would you like?
We have [RelationshipTarget::LINKED_SPAWN](https://docs.rs/bevy/latest/bevy/prelude/trait.RelationshipTarget.html#associatedconstant.LINKED_SPAWN) which works for despawn and cloning. I'd suggest to extend it to the relationship target component removal.
Contributor guide
Assessment
This issue has not been assessed yet.