bevyengine / bevyengine/bevy

Despawning entities should silently fail if the entity does not exist

Open
#5,617 21 comments 9 reactions 0 assignees View on GitHub
A-ECS C-Usability M-Migration-Guide S-Needs-Design X-Needs-SME
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## 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.

Contributor guide

Open the contributing guide

Research direction

Start by locating the implementation and tests for the `commands.entity(my_entity).despawn()` entry point. Confirm the current behavior when the entity does not exist, then make the command complete without a panic in that case. Done means despawning an existing entity still works and despawning a missing entity fails silently.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
game-dev
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.