Optimizing AIController & Enemy character when streaming

I have a problem with streaming in my enemy characters and their AIControllers. It causes pretty big lag spikes on CPU and since i’ve never done anything remotely close to optimization I would like to get some advice where should I start. I know that behaviour tress load all tasks in and AiController is active at the start so my first thought was to try to do something about it. In behaviour tree i have about 20 pretty easy tasks switching between melee and ranged combat in addition to some movement paired with EQS. Bt itself doesn’t run anything except some basic varaible setting until the player is seen. My AiController is basicly just runing behaviour tree and assigning blackboard + pawn sensing.

I would love to hear from someone who had similar issue or can give me some tips how to approach this situation. If any more information is needed i will gladly provide it.

Not sure if you meant “Spawning” as I’ve not heard of Streaming AI.

One thing you can try is to not spawn them and destroy them constantly. Rather, edit and move them around.

If one dies, hide it and then unhide it back at its next spawn location rather than destroying it and spawning a new one. This way you can also just adjust the max number of AI and keep them inactive and hidden until they’re needed and you shouldn’t get any spikes.

Now if you want ragdolls, you can spawn one upon death at the moment you hide the actor and have it use “master pose component” to get the right animation frame. If THAT lags when it’s spawned, then you can have a 2nd ragdoll in your AI that you activate while you hide and move the original actor. When the ragdoll dissolves, you can hide it and wait for its next death location by again, reverting its location and animation pose to match the AI skMesh.