How to stop enemies when they are not on the screen in Behavior Tree and Optimization

I recently started to use behavior trees in Ue4. All is good but I need to disappear enemies when they are not close to the character for optimization purposes. I searched online for this but couldn’t find something that I can use.

Also, what is the best way to do this? I want them to almost not exist. Should I just destroy and spawn all over again?

The game type is similiar to Path Of Exile.

You can add a sphere collision component in your character bleuprint and use the end overlap to trigger the destroy or whatever you want to use, maybe you can just make them invisible or so and stop the behaviour tree.
good luck

After a quick research, I found this post:

You might want to try stopping / restarting logic for brain components of your AI controllers when the pawns leave / enter the player viewport.

Also you could set the visibility, but I don’t knowhow big of a performance hit this has when they aren’t rendered anyways.

If I misunderstood you, just comment below and please provide more information on what exactly you’re trying to achive.

Cheers

PS: Reading further in the thread mentioned above, you might be able to achieve something similar by just using Unposses and re-possessing the AI controller when needed.

I’m using this to determine the distance and I tried both posses-unposses and stop logic after this, None of it worked. AI continue to do what it’s told.

Is the option “Stop AILogic on Unposses” set to true in your AI controller?

Yes it is set true

Does anyone know?