Realistic Sniper and Ballistics
  • Welcome
  • Introduction
    • Feature List
    • Why/How is it used?
    • Quick Setup
  • Getting Started
    • Getting Started
    • Environment Properties
    • Bullet Properties
    • Object Poolers
    • Sniper and Ballistics System
    • Firing a Bullet
    • Listening to Hit Events
      • Spawning Particles on Hit
      • Hit Tags
    • Zero Distances
    • Wind Vector
    • Air Resistance
    • Spin Drift
    • Ballistic Surfaces - Penetration
    • Ballistic Surfaces - Ricochet
    • Bullet Time Effects
      • Target
      • Bullet
      • Firing with Bullet Time
      • Bullet Time Camera - Default
      • Writing your Own Bullet Time Camera
    • Dynamic Scope System
    • Incorporating Player
      • Player Movement Controller
      • Motion Controller
      • Camera Controller
      • Player With Weapon
    • Mobile Controls
    • Conclusion
  • API
    • API Welcome
    • Sniper and Ballistics System
    • Dynamic Scope System
    • Player Movement Controller
    • Motion Controller
    • Ballistic Surface
    • Environment Properties
    • Ballistics Utility
    • Bullet Time Utility
Powered by GitBook
On this page

Was this helpful?

  1. Getting Started

Object Poolers

PreviousBullet PropertiesNextSniper and Ballistics System

Last updated 3 years ago

Was this helpful?

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.

ObjectPooler.cs settings.

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.