11 hours ago, ferrous said:
Things that make projectiles slow:
Thanks for this it provided me with good focus points. Time is a scarce resource.
9 hours ago, frob said:
Profiling is important.
Yes, I fully agree. In the end it is the most effective way of finding problems.
11 hours ago, ferrous said:
3. Using an expensive to render mesh / sprite
So after some profiling I learned Unity batched the first few projectiles to save performance, then around the 40th projectile it just stop batching them. With sprites this didn't happen; it batched all of them.
After digging around in the manual and online I discovered that Unity's animated batching works best on meshes with +/- 200 vertices. I was using the Unity sphere primitive as the code is still in early testing. Changing the sphere to a cube proved that indeed the projectiles was too high poly.
Because the game is mostly from a top down view I can make only the top half of a projectile and projectiles won't need that many vertices. 200 would be more than enough. I will maybe even use sprites, for the projectiles that will have huge numbers.
At the moment I am even considering particle collisions, because it looks like this is a possible option, but I don't know if I will have the time to learn it.