I’m working on a little iphone game where u fight in an arena against several enemies.
Now, I wondering whats the best way to save as much performance as possible.
I’ve read about using an object pool but I’m a bit suspicious.
I have a maximum of 5 enemies on the screen and 10 different enemy types. The type is picked randomly.
So I need 5 enemies of every type which ends up in 50 enemies in total, which sounds a lot.
Is it really that good to create 50 skinned meshes and deactivate them?
They are still in the scene and will use a lot of memory/performance when they are deactivated. aren’t they?
If there are only so many alive at a given time, then your main problem is how much RAM your using. If you’re on desktop then RAM not such an issue and it probably won’t be a performance hit to instantiate a mob, but on mobile you will probably see a judder in frame rate. We instantiate all our mobs and may go to as many as 50, but we are on mobile so have some custom lod system to swap a skinned mesh renderer for a simple renderer on all but the nearest 5 mobs - we don’t want to animate more than a few!
We also plan to sleep the majority of mobs and activate them when the player gets to a trigger location (as they’ll be doing nothing until then anyway!)
We had a performance issue however with skinned mesh renderer as the first Sample() allocates resources, so we start a level with them all active, force a Sample() and then hide the ones deeper in the level.
With RAM you may find the meshes are instances too so you should profile outside the editor and see if the RAM is much different from 1 to 50.