Skip to content

Despawn entities on relationship component removal when linked spawn is enabled #20252

@Shatur

Description

@Shatur

What problem does this solve or what need does it fill?

The following code works:

let mut world = World::new();

let mut entity = world.spawn((
    Name::new("Root"),
    children![Name::new("Child1"), Name::new("Child2"),],
));

entity.remove::<Children>();

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 which works for despawn and cloning. I'd suggest to extend it to the relationship target component removal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-BugAn unexpected or incorrect behaviorD-ModestA "normal" level of difficulty; suitable for simple features or challenging fixesS-Needs-DesignThis issue requires design work to think about how it would best be accomplishedX-ContentiousThere are nontrivial implications that should be thought through

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions