dimanche 4 janvier 2026

Unreal Engine 5 : Pool Manager & Projectile Optimization

Features

Pool

Pool system is use to recycle memory and avoid to spawn actor every time it need. Even Unreal Engine have his owns system, every time we spawn actor, it's has to made all the process of actor instantation (memory allocation, component initialization, and constructor execuion, begin play etc etc) which are expensive. On game user can feel a hitch (CPU). 

 By using a pool system, actor are spawn at the beginning in the game on background (hidden,no tick,no collision). When player shoots, we extract a bullet from the pool and make it active

My pool have 2 array : _available_bullet and  _active_bullet . The idea is to eliminate useless iteraction to check to see if bullet is active. When a bullet is need, _available_bullet transfert his bullet to active_bullet. Add a actor on a array it' 0(1) and to avoid that when we delete the actor, array have to reorganize the array, we using RemoveAtSwap.

 Don't use Unreal Engine overlaps

Every time an actor are moving in Unreal. The engine have to : 

- Update Transforms to recompute actor location 
- Spatial Partitioning Update : Unreal reorganize his Bounding Volume Hierarchy , by moving the actor.
- And redo the Collision detection system. 

And this every time the bullet is moving, which happen quite a lot.
For a simple bullet which are moving straigh line it's may be too much. That why I remove the Projectile Component oftenly use on Projectile. Because the bullet goes straigh line, I don't need a heavy component like Projectile Component of Unreal. 

Instead I use a simple travel mathematic function (ActorLocation + velocity * deltatime) and for detection a SweepTrace is enough. The code always destroy bullet and don't manage the interaction.It'sa demo . I also remove Tick and Collision that way Unreal don't add for detection and Tick system which can be an optimization if the pool contain a lot of bullet

Github repository : https://github.com/NicolasBunn/UnrealEnginePoolSystem.git