This repository was archived by the owner on Oct 7, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 81
Removing Thinker #108
Copy link
Copy link
Open
Description
How would one remove a thinker from the entity?
Scenario
Big-brain powered goblin has been killed by Player. I want to remove "AI" components from the entity, so that only lifeless husk stays.
First idea
The most straightforward idea is to remove ThinkerBuilder, right?
// when killed event is triggered
commands.entity(event.target)
.remove::<ThinkerBuilder>();
I can see, that there is thinker_component_detach_system and actor_gone_cleanup
Problem
I'm getting:
2025-03-03T23:20:54.262069Z WARN system_commands{name="big_brain::thinker::thinker_component_detach_system"}:command{name="DespawnRecursive" entity=33v1#4294967329 warn=true}: bevy_ecs::world: error[B0003]: .cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bevy_hierarchy-0.15.2/src/hierarchy.rs:49:19: Could not despawn entity 33v1#4294967329 because it doesn't exist in this World. See: https://bevyengine.org/learn/errors/b0003
Weird... That despawn recursive is already guarded by if let Some(ent) = cmd.get_entity(*thinker)
Sometimes it fails in thinker_component_detach_system and sometimes in actor_gone_cleanup.
Perhaps my idea is incorrect and there would be a better solution?
Should I overwrite ThinkerBuilder with the one that has no scorers? I'd rather avoid having a flag IsKilled and checking it in every scorer/action.
KanarXD, Stumblinbear and xvrqt
Metadata
Metadata
Assignees
Labels
No labels