RSBDOCS
Getting started

Object poolers

Reuse tracers, particles, shells and trajectory renderers.

Create an empty Tracer Pooler GameObject and add ObjectPooler. Assign Objects/Bullet Tracer/Tracer.prefab to Pooled Object.

FieldPurpose
Pooled ObjectPrefab to instantiate.
Pooled AmountInitial number of instances; default is 20.
Will GrowInstantiate another object if all current instances are active.
Hide FlagsControl whether pooled instances appear in the Hierarchy.

The current implementation creates its initial pool in Start, not Awake. Request objects after initialization, normally in response to gameplay events. GetPooledObject() returns an available object; position and activate it yourself. A disabled instance becomes available again.

When growth is disabled and every object is in use, the method returns null. Check that result in your own listeners. The supplied tracer, trajectory and particle consumers expect an object, so keep growth enabled or size their pools for the maximum simultaneous use.

Use separate pools for impact particles, muzzle flashes, shell objects and LineRenderers. The supplied effect prefabs use timed deactivation so they can return to the pool. Reuse or add ObjectDeactivator when making your own effects.

GameObject effect = pool.GetPooledObject();
if (effect != null)
{
    effect.transform.SetPositionAndRotation(position, rotation);
    effect.SetActive(true);
}
Object Pooler fields for a tracer prefab.
Original RSB manual capture. Follow the current instructions on this page for paths and setup. Click the image for full size.