# How to delete / remove un-possessed AI Controllers?

**URL:** <https://forums.unrealengine.com/t/how-to-delete-remove-un-possessed-ai-controllers/286209>\
**Category:** World Creation\
**Tags:** Destroy, controller, ai-controller, unreal-engine, Blueprint, question\
**Created:** [June 18, 2014, 3:19pm UTC](https://forums.unrealengine.com/t/how-to-delete-remove-un-possessed-ai-controllers/286209 "2014-06-18T15:19:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![DrunkCompiler](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DrunkCompiler](https://forums.unrealengine.com/u/DrunkCompiler)\
**Post date:** [June 18, 2014, 3:19pm UTC](https://forums.unrealengine.com/t/how-to-delete-remove-un-possessed-ai-controllers/286209/1 "2014-06-18T15:19:05Z")

</div>

I’m only using blueprints for the following. I have 5 different characters, from a single base class (which inherits from CharacterClass). I’ve made a custom player controller that can posses the different characters. Also the characters follow (using navmesh and simple move to) the currently possessed character. The problem I’m having is that whenever I switch characters new AI Controllers are created but they aren’t being destroyed when I switch. These are the steps I’m trying to make sure that the controller are being destroyed but none of these actually work. The list of AI controllers keeps increasing in the scene outliner.

- Whenever I want to switch the possessed character I get the controller of the character to be controlled, cast it to AI Controller, and unpossess and destroy it. If cast fails I unpossess and destroy the controller.
- In LevelBP, using EventTick, I get all actors of class “AIController”, and using a for each loop get owner, check if owner is valid. If not valid I unpossess and destroy. ( I also tried casting the actor to an AI Controller, still didn’t work)

None of the above methods work and switching between characters keeps creating stray AIControllers.

Any help would be appreciated.

---

<div class="post-metadata">

**Author:** ![Shoiko](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shoiko](https://forums.unrealengine.com/u/Shoiko)\
**Post date:** [June 18, 2014, 3:49pm UTC](https://forums.unrealengine.com/t/how-to-delete-remove-un-possessed-ai-controllers/286209/2 "2014-06-18T15:49:25Z")

</div>

You should be able to reassign that original AI controller not create a new one. The way I do it is using the gamestate i pass in my controller and my Pawn and the next pawn and next AI controller that owns the next pawn.

Then Take My controller and possess they next pawn and have the next controller posses my pawn. This works with no leaks. Is there a reason to create a new AI?

---

<div class="post-metadata">

**Author:** ![DrunkCompiler](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DrunkCompiler](https://forums.unrealengine.com/u/DrunkCompiler)\
**Post date:** [June 18, 2014, 4:15pm UTC](https://forums.unrealengine.com/t/how-to-delete-remove-un-possessed-ai-controllers/286209/3 "2014-06-18T16:15:33Z")

</div>

Thanks for your reply. I don’t create new controllers, the engine automatically does it when I call SimpleMoveTo. I’ll try your method. Thanks.

---

<div class="post-metadata">

**Author:** ![DrunkCompiler](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DrunkCompiler](https://forums.unrealengine.com/u/DrunkCompiler)\
**Post date:** [June 19, 2014, 11:40am UTC](https://forums.unrealengine.com/t/how-to-delete-remove-un-possessed-ai-controllers/286209/4 "2014-06-19T11:40:53Z")

</div>

Yep that worked. I just switched the AIController and PlayerController. Thanks again.

---

<div class="post-metadata">

**Author:** ![egerge1y](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@egerge1y](https://forums.unrealengine.com/u/egerge1y)\
**Post date:** [June 17, 2023, 12:15pm UTC](https://forums.unrealengine.com/t/how-to-delete-remove-un-possessed-ai-controllers/286209/5 "2023-06-17T12:15:00Z")

</div>

“Detach From Controller Pending Destroy” Node working perfectly to me also. Destroy all (spawned)AIControllers (eg.: 100), then i can spawn another 1.

[https://forums.unrealengine.com/t/how-do-i-unassign-an-ai-controller-to-a-pawn/300470/7](https://forums.unrealengine.com/t/how-do-i-unassign-an-ai-controller-to-a-pawn/300470/7)

---

<div class="post-metadata">

**Author:** ![Metalmilk](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/metalmilk/32/959017_2.png) [@Metalmilk](https://forums.unrealengine.com/u/Metalmilk)\
**Post date:** [January 12, 2025, 6:01pm UTC](https://forums.unrealengine.com/t/how-to-delete-remove-un-possessed-ai-controllers/286209/6 "2025-01-12T18:01:22Z")

</div>

or mayby someone wonna grab a unposses actor by posses actor, but the grab character lose a controller, then just go to main character BP then in \>class default\> in movement /advance switch on RUN PHYSICS WITH NO CONTROLLER…
