On the topic of ArrayList vs Array, if I were going to be resizing the array constantly (not every Update, but fairly frequently) thus having to make my own add / remove functions, is the built in array STILL faster, or would the ArrayList take the lead when using dynamic lists?
Would it be worth to convert the built in Array to an ArrayList while resizing, then back to an Array for iteration, or is that slower than just using the ArrayList only?
I am mainly using this for tracking when enemies enter and leave area triggers. OnEnter, add to the array. OnExit (or die) remove from the array. When an enemy enters or leaves the collider, I will iterate through the array to get my new target based on a value. This will potentially happen on 1-50 objects whenever an enemy object triggers the collider.
It also makes me wonder if a sorted array is faster for this sort of project, or if it is faster to just iterate through the array of ‘n’ objects each time.
Another question is should I have each enemy track their own value and just reference this value while iterating through them, or if I should just calculate this value at the time of iteration.
I would love it if there was a Javascript profiler. I tried to use and convert the C# one in the Wiki, but to no avail.
Please let me know if you have any ideas or experience with these sort of questions.
It’s unlikely that traversing an array of only 50 objects is going to be the major bottleneck in your application.
Personally, I try not to think about optimization until there is in fact a performance problem, since predicting bottlenecks is very, very difficult. Once you do notice a performance issue, a profiler is the first thing to look for. Sadly, Unity does seem to be lacking in that area.
My advice is not to worry about the array performance until you actually have a performance problem and know for sure that it is caused by the array code. Optimized code is often more complicated and harder to understand, so it’s a shame to use it when not needed.
Yeah, make the game first and worry about performance second. Speed gains with 50 objects will be instantly trumped by something higher-level. You could spend an hour optimizing your arrays and gain 1/1,000th the speed of spending 10 minutes optimizing your physics collisions volumes, etc.
Great advice all around - sorta validates what I always say - “don’t worry until you have too…” 
-Will
Ok, sounds good. I guess I was mainly looking for any sort of standard the community has found. Such an example, I was using the character physics quite liberally, and was running into a bit of a slow down. A couple of users has suggested to use rigid body movement instead of a character controller, and it has improved performance quite a bit.
It has been said before, make it work first, then make it work fast.
Thanks for your advice.
P.S. I am not traversing an array of 50 objects. 50 objects will be traversing their own arrays, and these will be updated as objects enter and leave their colliders.