Skip to content

Observers not getting despawned on DespawnOnExit #22111

@zwazel

Description

@zwazel

Bevy version and features

  • 0.17.3
  • default + serialize + experimental_bevy_feathers + bevy_dev_tools + track_location

What you did

I want to have observers spawned in when entering a state, and despawned when exiting the state. so i have a system spawning in an observer when entering it, and spawning them with the DespawnOnExit component:

commands.spawn((
    Observer::new(handle_new_client),
    DespawnOnExit(IsHost),
));

What went wrong

  • I'm expecting them to be despawned
  • they don't get despawned

Additional information

the bevy system despawn_entities_on_exit_state does not have the With<Internal> or other filter, so will get ignored because of the DefaultQueryFilters.

If this is intended, i feel like maybe have that in the doc comment of DespawnOnExit and co?

I just noticed, the despawn_entities_on_enter_state system has an Allow<Disabled> filter

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsA-StatesApp-level states machinesC-BugAn unexpected or incorrect behaviorS-Needs-TestingTesting must be done before this is safe to merge

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions