Skip to content

Adding an entity using a RelationshipTarget #18662

Open
@Freyja-moth

Description

@Freyja-moth

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

Currently there is no way to add multiple relationships with one entity using the new RelationshipTarget

If I wanted to spawn something that is in multiple relationships (scandalous) there's no way to express this with the new spawning api.

let character = commands.spawn(RandomCharacter).id();

commands.spawn(Organization).add_one_related::<InOrg>(character);

commands.spawn(Town).add_one_related::<InTown>(character);

What solution would you like?

A new method on RelationshipTarget that takes an entity(s) instead of a bundle.

let character = commands.spawn(RandomCharacter).id();

commands.spawn((
    Town,
    // Not sold on the name, I'm sure there's something better I could come up with but brain is hardly braining.
    Residents::from_entity(character),
))

commands.spawn((
    Organization,
    OrganizationMembers::from_entity(entity)
));

And possibly some way of doing it with the macros, though I'm not sure how.

What alternative(s) have you considered?

Doing it the way shown above, while it works it doesn't allow me to take advantage of the new relationship spawning api which is a shame.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useS-Needs-DesignThis issue requires design work to think about how it would best be accomplished

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions