Whats the performance of PawnInterator and similar?
Hi, im making some AI systems(Rocket new AI is awesome but not even close to be used) and ive added some things like OnSeePawn event to my controller and noise signals. What im doing with the OnSeePawn its to do a PawnInterator and check angle and trace if he can be seen. But im not very sure of whats the performance of that iterator, and as its something i do several times a second(its a timer), on every AI, i want to know if its performance hungry or not. I would optimize it by storing those pawns in a array in the gameinfo, and instead of using the iterator, grab the pawns from there. Iterating from that its kinda fast. But, of course, if the performance of PawnIterator is minimal, i dont need to do that. Exactly the same with another interface im doing to detect sounds. I have a "DoNoise" function wich sends a message to all close AIs, and i have to iterate trough an iterator. I can also do what i said above, storing them when they are created and use that, but it adds some overhead causing me to take care that every AI registers itself and unregisters when dies/gets destroyed. On short, if the PawnIterator and ActorIterator are usefull and dont take too much performance compared to just storing them somewhere.
asked Mar 11 '14 at 02:40 AM in C++ Programming
ue4-archive ♦♦ STAFF
I know that ActorIterator got a massive acceleration recently, as did ObjectIterator,
post on my question about actoriterator:
Obviously there is nothing faster than iterating only over an actor array that you yourself create and maintain,
but the additional code and array maintenance required could be large enough to offset any gains from the slightly shorter list that you are iterating over.
In my own experience of iterating over actor lists constantly, ObjectIterator and ActorIterator are so fast that I would never want to do all the array maintainence myself and forsake the convenience and accuracy of ActorIterator
Huge advantage of ActorIterator is that it is always accurate!
You never have to wonder if you mismanaged the array somehow
so for gain of engine-level accuracy of what actors are actually currently in the game, any price of checking a few extra actors is worth it to me.
It removes an entire layer of wondering from your mind when you are trying to debug something, if you know that the actor array is always accurate!
In the process of game development, you could use actoriterator for accuracy and ease now, and ultimately make things more complicated for yourself later on, much later, after all the core code is in and debugging has been done.
Project will grow much faster that way :)
And you'll probably never end up going back and making this more complicated for yourself anyways :)
answered Mar 11 '14 at 02:40 AM
ue4-archive ♦♦ STAFF
Follow this question
Once you sign in you will be able to subscribe for any updates here