Object Pool & Object Pooling System
Object Pool is software design pattern that allows creating objects in advance (e.g., at the scene loading) and then reuse them, what has a positive effect on game performance for Unity Projects.
Object Pooling, Optimization and Performance in Unity
To prevent Garbage Collector issues (CPU Spikes) in games with many spawning and destroying objects, a method called Object Pooling can be used. Object Pooling refers to creating all necessary objects beforehand and disabling/enabling them when it necessary, instead of instantiating (Instantiate() function) and destroying (Destroy() function) objects during runtime.
This is often done by having an array containing disabled objects that are often used, e.g. bullets in FPS or units in a Strategy game. When a gun is fired, instead of spawning a new bullet and allocating memory for it, we take a game object from the list (object pool), move it to the right position & activate it.
When the bullet collides with something, instead of destroying it, we disable it and add it back our object pool in default state to use it later.
This way we can have many objects appear and disappear, without allocating any memory and causing issues with the Garbage Collector.
These objects can also be spawned beforehand during a loading screen and kept hidden until needed. This way they won’t cause performance issues when spawned during gameplay.
Pool Boss — the best pooling solution on Unity Asset Store that makes simple to avoid the costly Instantiate() and Destroy() calls that cause performance problems. All types of prefab are supported — even particle systems.
One short line of code can despawn or spawn prefabs, or you can use our included Playmaker scripts!
Pool Kit — Ultimate Object Pool Manager, next generation system for pooling, spawning and despawning with ZERO Garbage Collection which can be up to 77% faster than instantiating (~33% on average) and helps to make your game a smoother experience which is increasingly needed on platforms like mobile, AR and VR!
Pool Kit also thinks about how you work in Unity and comes with its powerhouse of a Spawner. This can be used to create enemies in strategy or tower defense game genres, special effects, weapon systems and more!
Random Object Pooler
Random Object Pooler — improved version of the Object Pooling System by Unity Technologies.
Package is a Part of Unity Assets by Makaka Games
Random Object Pooler is available as a part of Complete Project Templates & Tools:
AR Shooter (docs).
Game Examples with Object Pool
First, read the latest docs online.
If it didn’t help, get the support.