Object Poolers

RSB uses object poolers to handle spawning/instantiating prefabs that will be used during simulation. These prefabs can be bullet tracers, in-game trajectory renderers, hit particles etc. In order to safely handle object instantiation in an optimized manner, RSB makes use of Object Poolers. Create a new empty game object in your scene and name it Tracer Pooler. We will later on use this object to pool tracers, visualized objects simulating bullet tracers. Add the component ObjectPooler.cs on it.

You need to assign the Pooled Object field as a prefab in your project folders. Navigate to InanEvin>Realistic Sniper And Ballistics>Objects>BulletTracer folder and drag & drop the tracer prefab into the slot. You can leave the other settings as default. What this will do is that when you start your scene, this script will instantiate Pooled Amount of bullet tracers in awake, disable them all and keep them in a list. Later on, our system will request a new tracer object whenever it is needed, and this script will return an available one from the list, without instantiating. This way, we delegate the instantiation of prefabs to the Awake(), saving us the runtime performance drop of instantiating. The same approach will be used on any other type of instantiation, for in-game trajectory renderers, hit effects, muzzle flashes etc.

Last updated