A few minor things with your code.
- This is speculation, I haven’t looked into how it works, but it may be faster to use TActorIterator and check each one for having the relevant component, rather than using an object iterator. That way the issue of finding objects not in the world is also taken care of.
- You’re calculating the difference vector twice, so cache it: RelativeLocation = TargetLocation - MyLocation.
- Compare the squared distance rather than the distance. Precalculate MaxSearchRadius * MaxSearchRadius, then compare that with RelativeLocation.SizeSquared().
- GetActorForwardVector() will already be normalized, so just use it as it is.
- Since your search radius is big, you’ll do most culling through your cone test, so it’s probably best to put that before your distance test.
Even then there would still be a little redundancy in there using both SizeSquared and GetSafeNormal, which you could get rid of, but I think that would come under premature optimization at this stage.
Still, just a couple of hundred seems like a low limit to be getting. What kind of number of actors with the component do you have? Also, you removed the cone collision from the missile, but presumably still have some collision component for testing for target hits. Is it just a sphere? Can they collide with each other? And what about on the target actor/component side? It’s possible you’re still being limited by the collision overlap testing.