SPAM Framework Documentation

Pooling

Pooling is a common performance technique used in games. Pooling, or object reuse, is done out of the box in SPAM with very little configuration needed. Since no allocation is permitted after startup, abilities spawn the objects they need and then reuse these across casts.

There are however two specific objects that are commonly reused across abilities, and these are given a little more configuration options: _Projectiles_ and _On Hit VFX_.

Pooling window

Pooling for Projectiles and On Hit VFX is configured through the Pooling Window. The configuration you set here is read once at startup and then cached, so any changes made won't take effect until you restart the game (exit and re-enter play mode in the editor). The settings are are saved to SPAM-Data/Resources.

_VFX_
All VFX that have On Hit VFX Instance set to Shared Pool will show up here. They will be spawned "On Demand", i.e when an Ability first requests it on start. Each VFX creates one pool, and all abilities using this VFX will use that shared pool, so take this into consideration when you decide how many instances to spawn.

_Projectiles_
Projectile abilities will try to resolve their projectile pool on startup if none is assigned in the inspector. When doing this, the values in the pooling window will be used.
Each projectile ability creates one pool, and all instances of this ability will use this shared pool. Take this into consideration when you decide how many projectiles to have in the pool.

This operation can be quite costly if you have many different projectile abilities, since all pools needs to be created and filled at start. You can reduce this startup cost by creating pools in the scene at edit time instead of letting SPAM resolve it for you.
You can create a pool in multiple ways:

You can also pre-fill the pools with the current number of items as you have set in the pooling window, by checking the "pre-fill" checkbox.

Backlinks: