Skip to content

Latest commit

 

History

History
381 lines (278 loc) · 6.65 KB

File metadata and controls

381 lines (278 loc) · 6.65 KB

ObjectPoolingSubsystem - Complete Blueprint Guide

Learn how to use Object Pooling entirely in Blueprints!


Table of Contents

  1. Setup
  2. Creating Poolable Actors
  3. Pool Creation
  4. Spawning
  5. Examples
  6. Troubleshooting

Setup

Enable Plugin

  1. EditPlugins → Search "ObjectPooling"
  2. Enable "ObjectPoolingSubsystem" ✓
  3. Restart editor

Verify

  1. Open Content Browser
  2. Create new Blueprint Actor
  3. Parent Class: Search "AObjectPoolingEntry"
  4. Can see it? → Plugin working! ✓

Creating Poolable Actors

Step 1: Create Blueprint Actor

  1. Right-clickBlueprint Class
  2. Parent: AObjectPoolingEntry
  3. Name: BP_MyPooledActor
  4. Save and open

Step 2: Add Event Graph

Add these events (right-click → Event → search):

Event On Initialize In Pool

├─ Set Custom Property to Default
├─ Set Location to 0,0,0
└─ [Reset all state]

Event On Spawn Actor

├─ (Optional) Print String "Spawned!"
└─ [Startup logic]

Event On Despawn Actor

├─ (Optional) Stop All Audio
└─ [Cleanup]

Pool Creation

In Game Mode Blueprint

  1. Open BP_GameMode (or your game mode)
  2. Event BeginPlay
  3. Right-click → Spawn Actors Pool List By Class

Configure Nodes

Spawn Actors Pool List By Class
├─ Element Class: BP_MyPooledActor    (Your actor)
├─ Spawn Amount: 50                   (Initial)
├─ Max Spawn Amount: 200              (Maximum)
├─ Extend On Empty: True              (Allow growth)
└─ Spawn Timer Rate: 0.02             (Spawn speed)

Create Multiple Pools

Chain multiple nodes:

Event BeginPlay
├─ Spawn Actors Pool List (Projectiles)
├─ Spawn Actors Pool List (Effects)
└─ Spawn Actors Pool List (Enemies)

Spawning

Basic Spawn

Some Event (e.g., Input)
│
├─ Spawn Actor From Pool
│  ├─ Actor Class: BP_MyPooledActor
│  ├─ Spawn Transform: [Your location]
│  └─ Out Actor: [Get from output pin]
│
├─ Is Valid (Out Actor)
│  ├─ True: Use the actor
│  └─ False: Pool exhausted

Spawn with Auto-Return

Spawn Actor From Pool
├─ Actor Class: BP_Explosion
├─ Spawn Transform: Explosion Location
├─ Return After Lifetime: True         ← Enable this
├─ Lifetime: 3.0                       ← 3 seconds
└─ [Returns automatically after 3s]

Spawn and Store Reference

Create Variable: CurrentActor (Actor)

Spawn Actor From Pool
├─ [Configure]
└─ Out Actor → Set CurrentActor

Later - Use:
├─ Cast CurrentActor to BP_MyActor
└─ [Call functions]

Examples

Example 1: Projectile System

Setup (Game Mode BeginPlay):

Spawn Actors Pool List By Class
├─ Element Class: BP_Projectile
├─ Spawn Amount: 100
├─ Max Spawn Amount: 300
├─ Extend On Empty: True
└─ Spawn Timer Rate: 0.02

Fire Event:

Event Fire Weapon
│
├─ Spawn Actor From Pool
│  ├─ Element Class: BP_Projectile
│  ├─ Spawn Transform: [Weapon location]
│  └─ Out Actor: [Get result]
│
├─ Is Valid
│  └─ Cast to BP_Projectile
│     ├─ Launch
│     └─ Set Owner

Return (On Hit):

Event On Hit
│
├─ Apply Damage
│
└─ Despawn Actor (Self)

Example 2: Visual Effects

Setup:

Spawn Actors Pool List By Class
├─ Element Class: BP_Explosion
├─ Spawn Amount: 30
└─ Max Spawn Amount: 100

Play Effect:

Event Explosion at Location
│
└─ Spawn Actor From Pool
   ├─ Element Class: BP_Explosion
   ├─ Spawn Transform: Location
   ├─ Return After Lifetime: True
   └─ Lifetime: 3.0
   
   [Auto-returns, no cleanup needed!]

Example 3: Enemies

Setup:

Event BeginPlay
│
└─ Spawn Actors Pool List By Class
   ├─ Element Class: BP_Enemy
   ├─ Spawn Amount: 50
   ├─ Max Spawn Amount: 150
   └─ Extend On Empty: True

Spawn Wave:

Event Start Wave
│
├─ For Loop (0 to 30)
│  │
│  ├─ Spawn Actor From Pool
│  │  ├─ Element Class: BP_Enemy
│  │  ├─ Spawn Transform: Random Location
│  │  └─ Out Actor: [Enemy]
│  │
│  └─ Is Valid (Enemy)
│     └─ Cast to BP_Enemy
│        ├─ Set Target: Player
│        └─ Add to Array

On Enemy Death:

Event On Enemy Death
│
├─ Remove from Spawned Array
│
├─ Is Array Empty
│  ├─ True: Start Next Wave
│  └─ False: Continue

Troubleshooting

OutActor Always Null

Fix 1: Create pool first

✓ Call "Spawn Actors Pool List By Class" in Event BeginPlay FIRST

Fix 2: Increase pool size

Max Spawn Amount: 100  →  300
Extend On Empty: False →  True

Fix 3: Check actor class

✓ Element Class must inherit from AObjectPoolingEntry

Actors Not Showing

Fix:

In BP_MyPooledActor → Event On Spawn Actor
├─ Ensure visibility (already set by system)
└─ Check SetActorHiddenInGame(false)

Frame Rate Drops

Fix:

In Project Settings → ObjectPooling Subsystem
├─ SpawnPerBatch: 40 → 20  (slower but smoother)
└─ DestroyPerBatch: 40 → 20

Memory Growing

Fix:

Max Spawn Amount needs realistic limit

Bad:  100 initial, 10000 max, expandable
Good: 100 initial, 300 max, expandable

Best Practices

DO

  • ✓ Create pools in Event BeginPlay
  • ✓ Check if actor is valid before using
  • ✓ Use auto-return for effects
  • ✓ Use manual despawn for enemies
  • ✓ Set reasonable max sizes

DON'T

  • ✗ Create pools during gameplay
  • ✗ Forget null checks
  • ✗ Set unlimited max sizes
  • ✗ Spawn thousands at once
  • ✗ Leave pools uncleaned

Quick Reference

Task Node
Create pool Spawn Actors Pool List By Class
Spawn actor Spawn Actor From Pool
Check valid Is Valid
Return to pool Despawn Actor
Get placeholder Get Object Pooling Placeholder

Parameter Guide

SpawnActorsPoolListByClass
├─ Element Class: Your BP_Actor
├─ Spawn Amount: 50-200 (initial)
├─ Max Spawn Amount: 100-500 (limit)
├─ Extend On Empty: true/false (growth)
└─ Spawn Timer Rate: 0.01-0.05 (speed)

SpawnActorFromActorListByClass
├─ Actor Class: Your BP_Actor
├─ Spawn Transform: Location
├─ Out Actor: (receive result)
├─ New Owner: (optional)
├─ Return After Lifetime: true/false
└─ Lifetime: 5.0 (seconds)

Version: 1.0 | All Blueprint, No C++! 🎨