Skip to main content
‹ Back to Tutorials
Intermediate Unity

Unity Bullet Pooling & Firing for Flight Sim Gameplay

Oct 16, 2023
About this tutorial

Learn how to take your Unity flight sim gameplay to the next level with bullet pooling and firing techniques. In this tutorial, we'll dive into creating an efficient bullet-pooling system and demonstrate how to fire bullets for a more dynamic experience. My discord link ► https://discord.gg/DgUdNDT

Written Guide

Instantiating and destroying bullet objects every time the player fires is one of the most common performance mistakes in Unity. Every Destroy() call feeds the garbage collector, and on mobile that shows up as visible hitches. The fix is object pooling: create all your bullets once at startup, then just toggle them on and off. This guide recreates the video's pooling setup using Playmaker and the free Pooler actions from the Ecosystem.

Step 1 — Build the bullet prefab

Create a sphere, name it Bullet, and scale it down to bullet size. Add a Rigidbody and disable gravity — the bullet should fly straight, not fall. Tag it 'Bullet' (create the tag if needed) and give it an emissive orange URP material so it glows. Reset its position to (0, 0, 0) before turning it into a prefab.

Step 2 — Give the bullet its own behavior

Add a Playmaker FSM to the bullet with an idle INIT state. Create a 'Bullet On' event and mark it as a global transition — that's what lets any other object (the pool manager) tell this bullet to activate. In the activated state, use Translate to move the bullet forward along its Z axis (around 4 units per second is a good starting value), then a Wait action of about 4 seconds, then a 'Pooler Destroy Self' action. Despite the name, this doesn't destroy anything — it deactivates the bullet and returns it to the pool for reuse. Drag the finished object into your project to make it a prefab and delete the scene copy.

Step 3 — Create the pool at startup

Make an empty GameObject (for example --Game Manager--/BulletPool) and add an FSM. In its first state, use 'Pool Create': assign the bullet prefab, name the pool 'bullets', and preload enough bullets that you can never run out at your fire rate — 50 is generous for most fire rates; 20 may be plenty for slow ones. Enable recycling so deactivated bullets become available again. The Pooler actions install from the Playmaker Ecosystem: search 'Pooler' and click Get.

Step 4 — Fire on input

After pool creation, transition to a wait state with a 'Get Key Down' action listening for the spacebar. On press, move to a state that uses 'Pooler Spawn' to grab an inactive bullet from the 'bullets' pool at a spawn point — an empty GameObject positioned just in front of the ship. Store the spawned object in a variable, then use Send Event to fire the global 'Bullet On' event at that specific object. Finish with a next-frame event back to the wait state to avoid an infinite loop within a single frame.

The result: 50 bullets created once at scene load, then endlessly recycled. Watch the hierarchy while firing — bullets simply blink on and off. No instantiation, no garbage collection spikes, and a noticeably smoother game.