[Plugin] Object Pool Component

Thank you for looking into this, but…

  • If we’re not to use the addcomponent dropdown list, then how do we add that component to an actor ?
  • if you mean the dropdown with the variable types ( these are also the same ), can’t we set a variable to the pool component type then ? to have a local reference to a pool component.

Another thing… that would make the plugin even more usefull:

Would it be possible to set the object pool count dynamically? I understand that you can’t or shouldn’t change it during runtime. That would defeat the purpose. But setting the size value once at runtime would be nice if this depends on other parameters. If you know and set the size by the time the actor containing the objectPool component is constructed or something, that should be possible to do right ?

Ok, i didn’t knew you could drag and drop a component to a blueprint actor’s components panel, so that one is solved.

When you create a component asset, it will appear in that same dropdown list, with the name gave you it; under the “Custom” components list.
I have already fixed the error of pools being displayed with the same name; the prototype classes won’t be in there anymore and you will be able to either create Actor, Pawn, Character pools directly from base classes or use assets if you create one (you don’t really need to create assets).

I was working on custom Lifespan for when you spawn characters on the Pool and correcting a problem with the “Tick” function ignored after “Spawn Actor from Pool” is called, devs have been requesting this;
Lifespan and bugfix for the Tick function are now complete so I can now investigate about a way to execute Blueprint’s Constructor Scripts when spawning an Actor from the Pool.

I am pretty sure that doing that will require development of a custom K2_ Node, it’s the only way I can think of accessing variables marked “Expose on Spawn” and update their values;
These K2 things are really tedious and troublesome the work with, but I’ll see what can do about it.

@FrederickD Okay… this Blueprint Node is going places :wink:
It literally gave me a headache because there’s zero% documentation for things like this and I fell into a rabbit hole of infinite casting stuff to blueprint pins and from pins all over the place…

  • Btw, I have no idea if this is going to work at all though; all it does for now is print a “-hello world, I’m alive!” lol *

Blueprint’s exposed parameters:

The custom K2 Node I’ve made to capture, and process, those parameters that have to change inside of a Construction Script for a ‘Pooled Actor’ when firing the ‘On Pool Begin Play’ event:

Step two will be taking those exposed properties and actually make them work when the Actor comes out of the Pool :stuck_out_tongue:

Oh boy… Got this working, finally; lol
Complicated stuff, but seems to work fine now, exposed properties are now being processed by the new Spawn node.
For some weird reason, I’m not really sure why yet, this node is giving our game even more framerates when we disable ‘Instantiate on Demand’ on Project Settings YaY:

Also, I’m receiving a lot of questions about the math to make a projectile move, since the “Projectile movement component” causes problems.
To makes things easier to everyone, I have created a custom Projectile component that you can use in your pooled bullets without worrying about annoying math stuff. Just attach a ‘Pool Projectice’ to your APooledActor bullet and it just works:

Well, now I have to:

  • Bug hunt more.
  • Implement the functions for Pools of Characters and Pawns.
  • Port from UE4.15 to earlier engines.

I’m not working on this all the time, so I hope to finish that last step somewhere by the end of this week, cheers.

XaVIeR when are those will be available to download? cant seem to find those updates

The new node and the projectile custom component are work in progress.

They are done for Unreal 4.15, but there’s still 1 small issue remaining: I don’t know yet how to add a second execution output to the custom K2 spawn node, due to engine’s internal blueprint compiler stuff…
I’m reading engine source code to plan the best route I’ll use to make conditional output between two result exec pins.

This custom Spawn node isn’t published yet.

So we need this Pool Projectile Comp to solve the issue when, some projectiles are “Stuck” [like they have no speed at all] ?

  • also when for example i have a pool of 60 , and i fire all those quick i get the Pool Spawner stuck and keeps Failing to spawn… i need to raise the pool accordingly to fire rate i suppose?
  • and … those actors are spawned into level [ex.60] will this behave like it spawns 60 actors the moment its created? like it will stuck for a bit ]
    -and are those actors counted+ each one for draw calls?

Yes, right now you’d have to code your own projectile logic; I have made this custom wrapper for the engine’s projectile movement component so then you won’t have to code the component yourself anymore;
But keep in mind that it’s still the default engine’s projectile component been used and that component generates garbage collection (if you code your own you could make it in such way that avoids firing the GC).

If you don’t want to increase the pool size, you can either enable instantiate on demand options (will create new bullets) or you can use GetSpawnedObject() and reuse one of the bullets that are still travelling * didn’t hit anything *.

I’m doing this, I store a pool of 20 bullets in player, if all 20 are shot and there’s no deativated actor available then I either let enabled Instantiate on Demand to create new bullets on the fly or I take back one of the bullets that are still travelling and re-shoot that one.
This way I avoid GC calls 100% of the time.

Drawcalls only count for actors that are active and visible (rendered); if there’s no mesh rendered then there’s no drawcall.

I’ve got the custom nodes working on all supported engine versions, and the custom projectile movement component is also finally complete:

Note:
This projectile component will not work properly with ‘Instantiate on Demand’ enabled; with this component involved, is better just not use IoD due to the way the engine registers components internally.
To compensate that, I have added an option to load the Pool’s actors only when needed as this process correctly registers the dynamic events needed to make the projectile components work:

I’m submitting this to Marketplace team pretty soon, I’ve cleaned up all possible bugs I can think of, feels like a pretty solid solution now.

Updated demo project and demo windows exe can be found here:

DEMO PROJECT 4.15]
PLAYABLE DEMO]

AWSD move
Keyboard Arrows shoot

Edit:

The plugin version with this new K2_ node and the pooled projectile component are now live on Marketplace =]

  • Removed my message. Had issues with character pooling but seem like there is something wrong in my end. Will report back after doing more testing, if finding something plugin related. Sorry for hassle.

The new functions doesn’t freeze ragdolls anymore. You may be having an issue with your physics assets going active by default.

Edit:

“On Pool Begin Play” of your Characters, disable “Simulate Physics” on the character and your ragdolls will turn off.
I will expose all these options as a checkbox, next update.

@SaOk So, the final blueprints will look like this:

With that in place, you will be able to configure and control absolutely everything that happens on the C++ component behind the scenes.
For your characters, just leave off the “Simulate Physics” checkbox and you won’t have the behavior you see currently.
That “Spawn Options” struct is now a permanent requirement though just like the Transform node attachment, because well I have exposed it all, so the Blueprint node is a now little bigger.

Thanks for details. :slight_smile: That new spawn actor node will come very handy. I seem to have some unknown collision sphere appearing in character blueprints that lifts character to air from ground. Cant click it in blueprint to find where it comes from. I deleted all component and reverted to make it hide. But it still seem to appear while playtesting. Could be something wrong in my side, but mentioning just in case.

The spawn nodes doesn’t create any component, so I don’t think it’s related.

@SaOk The latest changes with the bool check output pin are now published to the Marketplace, UE4.12 up to 4.15:

Note, the old spawn function have being deprecated in favor of this new K2 node; you still can have it in Blueprints, but Unreal will warn you that that node is deprecated when found it being used.

On some versions of Unreal this Plugin got a problem with float points imprecision;
The “Pool Lifespan” value sometimes is being interpreted as greated than zero and that is causing lifespan to trigger and Pooled Actors get deleted, some machines do not do that and some does;
I have fixed it and won’t happen anymore on update 1.3.5+.

Thank you for update!

I was looking at your Save/Load plugin. Got through 6 pages out of 8 but haven’t found an answer yet - does it integrate out of the box with Object Pool Component?

Yes they work well together because they are very unrelated, one won’t interfere on other one’s work.
All of them I’m currently using together on my projects (windows games that I don’t know yet if I gonna publish)


I’ve also improved compatibility with particles system components attached to APooledActors, they will also now be restored correctly on 1.3.5.