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.