[Plugin] Object Pool Component

1.0.1 for UE 4.15 have been submitted to Epic Marketplace Team.

Great to hear that character support is also in plans. :slight_smile: Have used own system for that, but this plugin makes it much more simple and manageable.

I have re-worked and optimized today the “Instantiate on Demand” function of the Pool;
And have added support for Pawn and skeletal Character classes to be pooled, this needs more testing. After more stability and stress tests I send 1.1 version over to Epic for an update somewhere at the end of this next week.


Looks like they are ready (reds are pawns and cyan are skeletal characters);
Just some more tweaking and more testing to go :slight_smile:

This is on my to-buy list :slight_smile:

I wonder why not to make it multithreaded. It could boost performance even further.

UObject cannot be threaded.

Hey got a few questions -
But first some background of the project.

I am currently working on a RTS that has a fair few amount of Skeletal Meshes and actors on screen at once.
Roughly 100 to 250 skeletal meshes max per player with up to 5 Players per side with up to 2 sides. I plan on making heavy use of this plugin.

Now here goes my questions -

  1. Does this work with the built in BP based vehicle class?
  2. I want to pool of various stats (Health, Armor, Morale, etc.) for of groups infantry and Vehicles. Is there any particular recommended way to handle this?
  3. Does this work with multiplayer?

Does it work with particle effects?

Yes, you just have to manually activate/deactivate the particle emitter on your Actor’s “On Pool Begin Play” and “On Pool End Play” events.

1: Right now it will not pool AWheeledVehicle class, but since it is a sub-class of Pawn, would take a few minutes to add now that Pawns are already supported.

2: Whatever you need to pool, at the moment must be a child of APooledXX classes; so if you have a blueprint that is child of any built-in in-engine class that cannot be pooled because it inherits the engine directly.
Right now anything child of AActor, APawn, ACharacter, they can be pooled fine: but if you have an engine class in the middle (such as AWheeledVehicle) the engine breaks the class inheritance; so best way to avoid problems for now is converting base AActor, APawn or ACharacter blueprints which can be converted to APooled one without breaking the game.

3: The pooling mechanism is not replicated for now; developers have to replicate it manually on multiplayer games, but I may change this in the near future once the core functionality is stabilished.

Hi Bruno Xavier

Your plugin should be usefull for open world maps.
Does it works with any characters BP, for example i have BP AI controlled characters including Behaviour Trees, does your plugin works also in that case ?

Yes, any blueprint child of ACharacter class can be pooled (when I submit the 1.1 update).
All you have to do is, like in the guides above in OP, reparent the base Blueprint Asset of your Character class to ***APooledCharacter ***instead of being a child of plain ACharacter;
That will not change anything in your code and everything will keep on working as usual in your Character like it was a direct child of plain ACharacter, but now with automatic pooling support.

1.1 with support for Characters and Pawns (with or without Skeletal Meshes) is now live on Marketplace.

Excellent, thank you. :slight_smile: How to enable the animation update tick after getting character from pool? I cant seem to find the right setting. Characters are listen in AB debug, but there is no tick. Using UE4.15.

Edit: Nevermind, now found it. Needed to activate mesh. Used toggle activation and that was wrong.

It picks the Tick option from your Character Blueprint asset.
If in the base Asset ticking is disabled then when coming out of Pool the Actor will not tick as well.

I have one question: can your system handle 100k actors ? (generation + rendering)

Right now, I am using hierarchical instanced static mesh to create and display those actors, as trying to render them separately was not thinkable in terms of performance (even by disabling ticking ability).

Does your plugin only solve the generation time, or also help improve the rendering time ? I am mostly interested in the rendering speed since I handled the generation in C++ and performance were roughly ok.

Nope, this plugin will not do anything to speed up GPU cycles.
After all we already have GPU Instancing for that.

Hi, this is most likely bug in my side, but I am having one AI character class that always have path following not simulating (and cant move) when taken from pool. Same time I have other AI character classes that work normally when taken from pool. Would you happen to know what settings are affecting the PF-component not to simulate? Been battling with the issue for days and cant spot differences between working/not working AI controllers.

Anyway, this have been amazing plugin. FPS stays much more stable.

EDIT: Sorry wrong alarm. I had max agents set too low in Project settings for crowd manager.

Object Pool {1.2.0}

Status: Updated

New API Functions:

C++ coders can use templated functions to cast directly, Blueprints have to cast manually.

(Object Pool Component):

  • GetObjectArray(): Directly access Actors storage, be careful what you do with this.
  • GetObjectsFromPool(): Returns two Arrays from the Pool, Spawned and Inactive member Actors.
  • GetSpawnedObjects(): Returns an Array of currently spawned Actors from the Pool.
  • GetInactiveObjects(): Returns an Array of currently inactive Actors in the Pool.
  • GetSpawnedObject(): Returns an Actor currently spawned from the Pool.
  • GetInactiveObject(): Returns an Actor currently inactive in the Pool.

Templated C++ Functions:

  • GetObjectsFromPool<T>(): Returns Array of Actors from Pool, type-casting to T.
  • GetSpawnedObjects<T>(): Returns Array of spawned Actors from Pool, type-casting to T.
  • GetInactiveObjects<T>(): Returns Array of inactive Actors in the Pool, type-casting to T.

(Pawn Pool Component):

  • GetPawnArray(): Directly access Pawns storage, be careful what you do with this.
  • GetPawnsFromPool(): Returns two Arrays from the Pool, Spawned and Inactive member Pawns.
  • GetSpawnedPawns(): Returns an Array of currently spawned Pawns from the Pool.
  • GetInactivePawns(): Returns an Array of currently inactive Pawns in the Pool.
  • GetSpawnedPawn(): Returns a Pawn currently spawned from the Pool.
  • GetInactivePawn(): Returns a Pawn currently inactive in the Pool.

Templated C++ Functions:

  • GetPawnsFromPool<T>(): Returns Array of Pawns from Pool, type-casting to T.
  • GetSpawnedPawns<T>(): Returns Array of spawned Pawns from Pool, type-casting to T.
  • GetInactivePawns<T>(): Returns Array of inactive Pawns in the Pool, type-casting to T.

(Character Pool Component):

  • GetCharacterArray(): Directly access Characters storage, be careful what you do with this.
  • GetCharactersFromPool(): Returns two Arrays from the Pool, Spawned and Inactive Characters.
  • GetSpawnedCharacters(): Returns an Array of currently spawned Characters from the Pool.
  • GetInactiveCharacters(): Returns an Array of currently inactive Characters in the Pool.
  • GetSpawnedCharacter(): Returns a Character currently spawned from the Pool.
  • GetInactiveCharacter(): Returns a Character currently inactive in the Pool.

Templated C++ Functions:

  • GetCharactersFromPool<T>(): Returns Array of Characters from Pool, type-casting to T.
  • GetSpawnedCharacters<T>(): Returns Array of spawned Characters from Pool, type-casting to T.
  • GetInactiveCharacters<T>(): Returns Array of inactive Characters in the Pool, type-casting to T.

(Pooled Actor, Pawn, Character Classes):

  • GetOwningPool(): Returns a direct reference to the Pool Component owner of this Actor.

Hi, I just bought the plugin.

Two things i’m wondering about, using Blueprint with 4.15…

  • One of the uses i had for it, needs the collision test override that spawnactor has. Not sure if that could be added, or that i will have to implement the collision check myself ? Maybe in c++ it’s just a function that the regular SpawnActor calls, that could be added ?

  • It also doesn’t support expose on spawn variables. how to get arguments to an object spawned from pool before or on the onpoolbeginplay fires? thus a bit like constructor scripts…

And another thing: In an actors add component list, all three are called the same, no difference between object, pawn or character pool. Same for the blueprint variable type panel. That’s a bit hit and miss to choose the right one.

Other then that, great work. Wonder why Epic hasn’t made something like this a first class citizen yet.

One more thing… From the Docs above, it wasn’t immediately obvious that you don’t need to create the component as an asset if you create the component inside an actor. Why would one create the component as an asset?

Hi @FrederickD

This dropdown list is a mistake on me, it shouldn’t be there and I will remove this.
The reason why you create an asset is because the classes you see from that dropdown list are “prototype classes” for your pool components, you should not use them directly as doing so you cause annoying issues with casting when your project grows.
If you pick a class from that list you are actually spawning a prototype class instead of creating your own pool component.

Emulating the behavior of Construction scripts on Actor pull is a complicated thing to do, I am still working on it.

The collision test can be performed manually, but I can add that to the plugin as well, this isn’t hard to change; I will make some changes to the plugin and send files to Epic next week.