The following reports from a world partition environment with spatially loaded and unloaded actors, which is cleaned-up on unload by the Unreal Garbage Collector.
After awhile the performance went down and it probably came down to how to deal with killed game actors. Perhaps even down to a single variable storing the target reference, the exact reason is unclear to me. An AI query gives pointers that the Unreal garbage collection (GC) can become a bottleneck when too many actors are killed, and or to many things are destroyed.
So I have set a couple of things like a PatrolComponent to be destroyed on spawn which may have contributed to it. The optimization here is to only add those components to actual patrol actors.
But the smart thing appears to not destroy at all, or only rarely.
Here are a few steps to temp remove an actor from the scene / view until it is returned - fake-respawned. Notice, that the following may be different in your project.
-
After killing an actor physics simulation is enabled, the character ragdolls to the floor. The capsule remains in-place.
-
Then the general disabling of the character
-
On re-turning the actor to live, the game, the physics simulation is disabled, and also requires to re-enable collisions, which are inconveniently disabled on simulation.
-
Because the character is in a different world position, the following puts him back up-right into the relative mesh space of the actor capsule.
And the default mesh position was stored once via the construction script
-
There are more settings depending on your AI setup, for example the following has been disabled, cleared
Notice that the highlighted target variables are important to be emptied too, otherwise the AI may not act as expected, i.e. moving randomly since it still has an active target set.
And then we restart the behavior again, the function reset contains all the on begin called behavior tree settings - I briefly set an empty behavior tree, which may be redundant.
And at last
And that’s it, the basics of how to return a character actor to the game without destruction.








