You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to add a relation between entities that are also parent / child of each other. My goal was to remove the need of iterating children looking for marker components.
// The relationship declaration#[derive(Component)]#[relationship(relationship_target = HairOf)]pubstructHasHair(Entity);implHasHair{pubfnnew(hair:Entity) -> Self{HasHair(hair)}}#[derive(Component)]#[relationship_target(relationship = HasHair)]pubstructHairOf(Entity);// Setuplet hair_entity = commands.spawn(Hair(character.get_hair())).id();
commands
.entity(character_entity).insert((Name::new(character.get_name()),HasHair::new(hair_entity),)).add_child(hair_entity);// later in a system
commands.despawn(character_entity);
What went wrong
It panicked with the following:
Encountered an error in command `<<models::greenfeet::body::HasHair as bevy_ecs::relationship::Relationship>::on_replace::{{closure}} as bevy_ecs::error::command_handling::CommandWithEntity<core::result::Result<(), bevy_ecs::world::error::EntityMutableFetchError>>>::with_entity::{{closure}}`: The entity with ID 97670v1 was despawned by .cargo\registry\src\index.crates.io-1949cf8c6b5b557f\bevy_ecs-0.16.0-rc.5\src\relationship\mod.rs:255:21
The text was updated successfully, but these errors were encountered:
OwlyCode
changed the title
Conflicting relations
Having a custom relation and a parent/child relation at the same time causes panics on despawn
Apr 23, 2025
# Objective
Fixes#18905
## Solution
`world.commands().entity(target_entity).queue(command)` calls
`commands.with_entity` without an error handler, instead queue on
`Commands` with an error handler
## Testing
Added unit test
Co-authored-by: Heart <>
Bevy version
0.16-rc5
What you did
I tried to add a relation between entities that are also parent / child of each other. My goal was to remove the need of iterating children looking for marker components.
What went wrong
It panicked with the following:
The text was updated successfully, but these errors were encountered: