I’ve been working on an action game for iOS in which a large number of projectiles and effects are being added and removed from the scene.
The projectiles tend to be sprites with a gameplay script, a spherical collision area and kinematic rigid body, and the effects tend to be sprites with just a game-specific script that determines their duration.
Early on, I just used Instantiate() to add bullets and explosions and such, but this preformed very poorly when many were added at once.
I later moved to the system of having a pool of each type of projectile that could be activated when ‘fired’ and de-activated when it would be destroyed. This resulted in a substantial improvement, however, on older iOS devices, the activation and de-activation of the gameObjects still caused a noticeable performance hit, especially in the case of bosses that shot large numbers of projectiles, or in the case where the player used a Contra-esque five shot spread weapon.
My final experiment was to not enable or disable anything, but simply to move the objects into the scene and then banish them when they were done. The problem here was that a massive spike in physics processing occurred whenever a projectile came on stage and began to move. Ultimately, this proved much less efficient than the second option.
The massive cache of banished projectiles were placed on layers such that they could not interact with one another but the presence of those active collision objects was heavily taxing to the distant objects when they moved, I suppose.
I feel like I must be overlooking a better fourth option for how to deal with this scenario. If there are any additional details that would aid the community in providing advice, I will be happy to provide them.