INTRODUCTION
While building gameplay systems in Unreal Engine 5, I created breakable objects that reward the player with collectible treasure items.
Initially, every destroyed object spawned a completely new treasure actor during gameplay. Although this worked for small tests, repeatedly spawning and destroying actors quickly became inefficient as the number of breakable objects increased.
To improve performance and scalability, I implemented an object pooling system for treasure actors.
SYSTEM GOALS
The pooling system was designed to:
• reduce repeated actor spawning
• improve gameplay performance
• reuse treasure actors efficiently
• support larger gameplay areas
• optimize breakable object systems
• keep gameplay systems scalable
WHY OBJECT POOLING?
Normally, gameplay systems constantly create and destroy temporary actors during runtime.
Example:
• break object
• spawn treasure
• collect treasure
• destroy treasure actor
Repeating this process frequently can increase memory allocations and runtime overhead.
Instead of destroying actors completely, object pooling allows actors to be reused multiple times.
The workflow becomes:
• request pooled actor
• activate actor
• use actor
• deactivate actor
• return actor back to pool
TREASURE POOL SYSTEM
A dedicated treasure pool manager stores reusable treasure actors inside an array.
CODE EXAMPLE
PRE-SPAWNING TREASURE ACTORS
Treasure actors are spawned once during initialization and hidden until needed during gameplay.
CODE EXAMPLE
REQUESTING A TREASURE FROM THE POOL
When a breakable actor is destroyed, the system requests an available treasure actor from the pool.
CODE EXAMPLE
USING THE POOLED TREASURE
After retrieving a pooled actor, the treasure is activated and positioned at the desired spawn location.
CODE EXAMPLE
RETURNING TREASURE TO THE POOL
Instead of destroying the treasure actor after collection, the actor is hidden and returned back to the pool for future reuse.
CODE EXAMPLE
GAMEPLAY BENEFITS
The pooling system improved:
• runtime performance
• gameplay stability
• memory usage
• scalability for larger levels
• responsiveness during gameplay
The system also reduced unnecessary actor creation during heavy gameplay interactions involving multiple breakable objects.
WHAT I LEARNED
Through this system, I improved my understanding of:
• object pooling architecture
• gameplay optimization
• actor lifecycle management
• scalable gameplay systems
• Unreal Engine 5 performance workflows
• reusable C++ gameplay design
Implementing object pooling helped me better understand how performance optimization becomes increasingly important as gameplay systems grow in complexity.
