How to efficiently simulate hundreds of instances of something at once?

I wish I knew more about the internals of UE4’s scene management. Do they use octrees to process object collisions or not, and if so, do we get access to it? I just haven’t needed to look into the internals yet and I probably wouldn’t know where to start digging for it yet. I’m assuming they use something really efficient, so it may be unnecessary to re-implement something like an octree if the backend already contains one which you can query against.

As for optimizations, I’d also consider setting a “target” reference within the heat seeking missile. It’ll lock onto this object at the beginning of its lifetime. Your “seek and relock on nearest heat signature” update can be run once every few seconds or at a random interval to fake the appearance of real time target switching. The fewer times you have to find a new heat signature, the better performance. You can also create a sphere centered on your missile. You know the missiles orientation vector, so you can use a bit of vector and angle math to find which objects lie within the sensory cone by comparing angles.

If you want, you can also try to avoid refinding valid heat targets every frame. Find those targets once every 5 seconds or so and store them in an internal list. Then process your seek AI against that internal list more frequently. You don’t have to run the expensive “find nearby stuff” method each frame, but you can still track them with a local list. Make sure to check whether these objects are valid though! if an object dies, it may still exist in your missiles list of known objects.