Skip to content

Cloning into and clone and spawn methods don't cover the same areas #23498

@Freyja-moth

Description

@Freyja-moth

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

Currently when trying to clone components into an existing entity the methods available are

commands.entity(entity)
    .clone_components::<Bundle>(other_entity) 
    .clone_with_opt_in(other_entity, |_| {})
    .clone_with_opt_out(other_entity, |_| {});

However when trying to clone components into a new entity the methods available are

commands.entity(entity)
    .clone_and_spawn()
    .clone_and_spawn_with_opt_in(|_| {})
    .clone_and_spawn_with_opt_out(|_| {});

Cloning components into an already existing is missing an equivalent to clone_and_spawn, and spawning a new entity and cloning components into it is missing an equivalent to clone_components.

What solution would you like?

Change clone_components to clone all components and add a clone_bundle that only clones the components in the bundle.

Add a clone_bundle_and_spawn method for spawning an entity with the cloned components in the bundle.

What alternative(s) have you considered?

Use the already existing clone_(and_spawn)_with_opt_* methods to cover the missing space, however these methods are quite low level and may be confusing for newcomers

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useD-ModestA "normal" level of difficulty; suitable for simple features or challenging fixesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!X-UncontroversialThis work is generally agreed upon

    Type

    No type

    Projects

    Status

    Needs SME Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions