Kevin H.on Game Development Stack Exchange • Recommends
On “Why should I always consider creating and using object pools instead of instantiating the new object on the fly?”
If you're planning to instantiate many instances of the same prefab, you should definitely think about using object pooling. Calling Unity's Instantiate function is one of the most taxing method calls you could make.
Object pooling is when you instantiate prefabs before they are used. They are deactivated immediately upon instantiation and reactivated only when they are needed. While this does increase memory usage, it avoids the CPU overhead of instantiating during gameplay.
For example, I'm currently working on a bullet hell game that requires hundreds of bullets to be spawned at runtime. I initially tried to make the game without object pooling but that ended up being a disaster ( les…