Ai controller can never be destroyed or be garbaged collected
In this example I spawn an Ai_Controller with zero references in this level and I can neither destroy it, nor make it get garbage collected. I have attached the test project.
asked Feb 02 '17 at 03:00 PM in Blueprint Scripting
Trying this in 4.21.1.
The AiController can't destroy itself "by design", best you can do is Destroy the BrainComponent (ie, The Behavior Tree) and stop tick, which at least will clear up some resources.
In C++ you can GetWorld()->RemoveController(YourAiController); but it doesn't work either...
So I guess AiControllers are here to stay?
answered Dec 14 '18 at 07:51 PM
I'm a bit confused as to why you're spawning an instance of the controller in your level. Could you elaborate on your reasoning for this?
This same setup works fine if the controller is possessing a pawn. For example, if you create a Pawn, assign it an AI Controller, and then inside the Pawn Get AI Controller->Unpossess->Destroy (make sure the AI CON reference is assigned to Unpossess and Destroy) it will destroy it as expected.
Also, I recommend giving this a try in 4.15 to see if the same issue occurs.
Let me know if you have any further questions and let me know the results of the 4.15 test.
Have a great day
answered Feb 02 '17 at 04:21 PM
Sean L ♦♦ STAFF
Follow this question
Once you sign in you will be able to subscribe for any updates here