unity3d - Sudden frame rate drops on mobile when instantiating/destroying? -


i working on mobile game , can't notice whenever object (an obstacle in case) instantiated or destroyed, sudden fps drop critical gameplay.

to give idea, instantiate obstacles on top of screen every 1.5 seconds, scroll them down. if obstacles reaches bottom of screen already, destroy them prevent memory leaks/waste.

i'm still pretty new unity development. on right track though? better solution prevent sudden frame rate drop?

do have big / nested loops or complex processes going off part of instantiation (look @ awake/start methods)?

regardless, object pooling better method handle type of thing.

for basic example, instead of creating/destroying projectiles of gun every time it's used, give gun "projectile pool" creates n projectiles when level loads. then, when shooting, set projectile's position gun , set projectile active. after impact, have projectile deactivate (or after few seconds if nothing hit).


Comments