Skip to content

Conversation

@Sigma-dev
Copy link
Contributor

Objective

At the moment, if someone wants to despawn all the children of an entity, they would need to use despawn_related::<Children>();.
In my opinion, this makes a very common operation less easily discoverable and require some understanding of Entity Relationships.

Solution

Adding a despawn_children makes a very simple, discoverable and readable way to despawn all the children while maintaining cohesion with other similar methods.

Testing

The implementation itself is very simple as it simply wraps around despawn_related with Children as the generic type.
I gave it a quick try by modifying the parenting example and it worked as expected.

@bushrat011899 bushrat011899 added C-Feature A new feature, making something new possible D-Trivial Nice and easy! A great choice to get started with Bevy A-ECS Entities, components, systems, and events S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels May 18, 2025
Copy link
Contributor

@bushrat011899 bushrat011899 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally don't see the harm in including these methods, and they're likely a good candidate for 0.16.1 as well. Just a couple nit-level changes to documentation to ensure users understand these are just helpers for the more general despawn_related.

Sigma-dev and others added 2 commits May 19, 2025 19:09
Co-authored-by: Zachary Harrold <zac@harrold.com.au>
Co-authored-by: Zachary Harrold <zac@harrold.com.au>
@Sigma-dev
Copy link
Contributor Author

Thanks for the feedback, I applied your tweaks.

@chescock chescock added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jun 6, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jun 9, 2025
Merged via the queue into bevyengine:main with commit 8cd5316 Jun 9, 2025
34 checks passed
github-merge-queue bot pushed a commit that referenced this pull request Jun 15, 2025
# Objective

- `remove_child` was mentioned missing in #19556 and I realized that
`insert_child` was also missing.
- Removes the need to wrap a single entity with `&[]` with
`remove_children` and `insert_children`
- Would have also added `despawn_children` but #19283 does so. 

## Solution

- Simple wrapper around `remove_related`

## Testing

- Added `insert_child` and `remove_child` tests analgous to
`insert_children` and `remove_children` and then ran `cargo run -p ci --
test`
@james7132 james7132 mentioned this pull request Aug 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ECS Entities, components, systems, and events C-Feature A new feature, making something new possible D-Trivial Nice and easy! A great choice to get started with Bevy S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants