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.

Hi Victor,

UWorlds maintain a pawn list, which PawnIterator uses, so this should be performant. The same holds true for the other iterators in World.h.

Cheers!
Jeff

Dear Victor,

I know that ActorIterator got a massive acceleration recently, as did ObjectIterator,

post on my question about actoriterator:

https://rocket.unrealengine.com/questions/13741/concerned-i-am-very-concerned-for-the-well-being-o.html

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 :slight_smile:

And you’ll probably never end up going back and making this more complicated for yourself anyways :slight_smile:

:slight_smile:

Rama

I wonder if you have made any measurements. Just out of curiosity.
How long would it take for 50 characters, to iterate over each other at the same time ?

I though about using actor iterator to gather information about actors that are hit and affected by character, and pass striped information back the UI, but I had some serious accuracy considerations, if I had to iterate over 1000 actors, over entire level, if I just need information about those 10 close to character.

Just to be clear I have solved this as well, with different approach.

I remember measuring looping inside ticker (hehe, I know that is plain stupid ;p), loop iterate over fairly small array of 4 elements, and there was also function to call over each ticker iteration.
In the end delay was from about 200 ms to even 400 ms, which i though was unacceptable, for the accuracy I wanted.
I have change it since, but now I’m quite wary of iterating over lots of data, when many actors must iterate over the same data at the same time.