Set up prefabs that should be pooled.
Object pools are found in System > Object Pools.
Object pooling can be used to increase the performance of your game and is best used for prefabs that are often spawned and destroyed, e.g. projectiles or particle effects. To use pooling in a scene, add Pool components for the pools you want to use.
Please note!
Combatant prefabs are not pooled. Each combatant instance is spawned and destroyed.
Object Pool Setup #
An object pool is based on a prefab and instantiates it when a level was loaded. The Start Size of the pool defines the quantity of objects that will be created at the start of a level. Pools can optionally grow by enabling Can Grow in the pool’s settings – this will add more objects to the pool when needed and keeps them alive, otherwise objects exceeding the pool will be destroyed again.
The pooled objects can be used by the prefabs defined in schematics. It’s only used when the prefab is defined as a resource in the schematic’s settings and has using pooling enabled. The prefab in the schematic and the pool must be the same prefab. If that’s the case, spawning and destroying a prefab in the schematic will get an object from the pool and enable/disable it instead of instantiating and destroying it.
Example #
The prefab missile is pooled with a start size of 10 and can grow.
The player’s control is handled by a schematic using the missile prefab as a resource with Use Pooling enabled. The same prefab as the pooled prefab is used, i.e. spawning this prefab will use a pooled object.
The level starts and 10 missile prefabs are instantiated and disabled immediately. The player fires missiles, they’re placed at the player’s position and enabled (Spawn Prefab node). When they hit a target or leave the screen, they’re disabled (Destroy Prefab node).
If the pool runs out of missiles, new missiles will be instantiated and added to the pool (i.e. they’ll also be enabled/disabled when used).
Using Pooling #
Pooling is a technique that will instantiate a pool of objects when a level was loaded and only enables and disables them afterwards instead of destroying them and instantiating new objects. Usually, this will help increasing the performance, but it can depend on the use case if it actually helps or has negative effects, since having a lot of objects alive in a pool (even disabled) also costs memory.
When to use Pooling #
As said, pooling costs memory for holding the objects, but increases the performance by removing the heavy instantiation and destruction of objects.
You should use pooling when objects are often created and destroyed, e.g.:
- firing projectiles, missiles, etc.
- particle effects
You shouldn’t use pooling for things like level architecture or procedurally generated levels, since those will most likely only be instantiated once and not destroyed until the level ends.
As noted above, combatant prefabs are not pooled.
Example #
E.g. the missiles fired by the player’s ship in a vertical space shooter are pooled. The player’s fire rate and the time a missile will be alive result in a maximum of about 15 missiles to be alive at the same time.
The pool size is 20 – this is a good use of a pool, but can also be reduced a bit.
The pool size is 100 – this is a waste of memory.
Pool Component #
The Pool component is used to add an object pool to a scene.
It’ll instantiate the selected pool’s prefab when the level was loaded (or when the component is added to the scene in a running game, e.g. spawning pools via prefabs).
Pools are only used in the scene they where added to, i.e. you need to add them to each scene they should be used in.

