Skip to main content

Pooled Actor

Custom Icon
Base:
AActor
Type:
ANPooledActor
Header File:
NexusActorPools/Public/NPooledActor.h

A specialized AActor base class that already implements INActorPoolItem and exposes each pool lifecycle hook as a BlueprintAssignable event. Use it as the parent of any AActor Blueprint that should participate in pooling without writing native code — the only thing left to wire up is your gameplay logic on the four lifecycle events.

The class is Abstract; subclass it (typically as a Blueprint) before placing or spawning instances.

What It Is​

  • Base Actor Class: Inherits from AActor so every standard AActor workflow continues to work.
  • Pool-Ready: Implements INActorPoolItem, so FNActorPool drives its lifecycle automatically.
  • Blueprint-Friendly: Each lifecycle hook is forwarded to a matching BlueprintAssignable event so designers can react without touching C++.

Key Benefits​

  • Drop-in Replacement: Reparent any AActor Blueprint to ANPooledActor to opt the class into pooling.
  • Automatic World-Boundary Return: Overrides FellOutOfWorld to call ReturnToActorPool() — Actors that cross the kill-Z return to their pool instead of being destroyed.
  • Consistent Behavior: Every subclass shares the same lifecycle event surface, so tools and editor utilities can drive any pooled Actor uniformly.

Lifecycle Events​

Each event corresponds to one of the INActorPoolItem callbacks. The native override calls into the interface (which advances the operational state) and then broadcasts the matching delegate so Blueprint listeners can run their own logic.

EventFires WhenBound INActorPoolItem Callback
OnCreatedByActorPoolEventPool first creates the Actor instance.OnCreatedByActorPool
OnSpawnedFromActorPoolEventPool hands the Actor out via Spawn.OnSpawnedFromActorPool
OnReturnToActorPoolEventActor returns to the pool (manually or via FellOutOfWorld).OnReturnToActorPool
OnReleasedFromActorPoolEventPool releases the Actor (e.g. during Clear — the Actor is also destroyed when bForceDestroy is true).OnReleasedFromActorPool

All four are UPROPERTY(BlueprintAssignable) instances of FOnActorPoolDelegate (no parameters). Bind them in Blueprint or via AddDynamic from C++.

World-Boundary Behavior​

virtual void FellOutOfWorld(const UDamageType& dmgType) override
{
ReturnToActorPool();
}

The base AActor implementation destroys the Actor when it falls below the world's kill-Z. ANPooledActor swaps that destroy with a return — useful for projectiles, debris, or any pooled Actor where falling out of bounds is a legitimate path back to the pool.