Skip to content

Despawning entities should silently fail if the entity does not exist #5617

Open
@alice-i-cecile

Description

@alice-i-cecile

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

Panics when working with commands are extremely frustrating, and difficult to debug or guard against.

What solution would you like?

We can reduce the pain in the common case by making commands.entity(my_entity).despawn() fail silently if the entity does not exist.

There is no real risk to doing so, as the desired state is completed. This is also useful as it makes despawn commands idempotent, making them significantly more robust and easier to work with.

What alternative(s) have you considered?

#2004 represents a more complete solution, but is dramatically more complex. This is also a better default for this particular command.

Additional context

We may also want to change the behavior of other commands, but that should be done in separate PRs to avoid blocking this less controversial change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useM-Needs-Migration-GuideA breaking change to Bevy's public API that needs to be noted in a migration guideS-Needs-DesignThis issue requires design work to think about how it would best be accomplishedX-ControversialThere is active debate or serious implications around merging this PR

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions