[Plugin] Object Pool Component

@Sononeo Oh okay…
On a new clean project I can get the crash.

Change line 119 from this:



if ( (OwningPool && OwningPool->ReinitializeInstances ) || (SharedPool && ***OwningPool***->ReinitializeInstances) ) {


To this (stupid me):



if ( (OwningPool && OwningPool->ReinitializeInstances ) || (SharedPool && SharedPool->ReinitializeInstances) ) {


I read through that line some 5 times and I didn’t see that before… :mad:

Yup, I am on Unreal 4.25.3.

If you edit the source like above and make a build the crash will stop.
That’s a dumb typo (helped by code auto completion feature).

I sent fix to Epic again few minutes ago btw.

Great!

Thank you, I’ll check that out once it goes live.

In the mean time I don’t know how to rebuild plugins. Editing the source is one thing but the dlls are what the engine/project is using so I’ll have to take some time to work that out and see if I can check that fix for myself locally.

Hey! Just wanted to say I tested the fix and it works fine now!

Thank you for being so responsive and sorting it out so quickly

Hey, love the plugin. Just a few questions about object life cycles. I had been using the world Kill Z to eliminate the kind of objects I’m now pooling. I realized these don’t get sent back to the pool automatically if the world destroys them. I’ve made changes to manually return objects to the pool now but I was wondering if it’s possible to just have pool objects automatically return to the pool whenever they or their parent are marked for destruction by the world? That would be useful for me. For instance the way my game world is structured the player moves past a lot of these objects during play and I’m destroying sections of the level when they fall behind the player. Those sections had previously spawned their own layouts of pool objects (inside a global object-pool component I keep inside the GameMode class). It would be nice if I could just attach those pool objects to the level fragments and then have them automatically returned when those fragments are themselves destroyed.

Make sense? Anyway I also just had a quick question about “Return to Pool” itself. If I called that on a pool object that was orphaned or that was spawned as a regular actor because the object-pool had no free objects left will it still be destroyed and cleaned up like a regular actor?

Thanks

@jivebowie that is not possible without modifying source and building your own branch of the engine.

Orphaned Actors can be destroyed as usual.

Thanks. I know I can destroy orphaned actors but how do I know they’re even orphaned if my object-pool has “Instantiate on Demand” checked? It’s possible this new instance is outside of the pool so a call to “Return to Pool” would do nothing and what you’re saying is that it doesn’t automatically destroy such an actor yes? Should I check that the Owning Pool is valid on all instances I’m returning to pool so I can destroy them instead if need be?


When the owning pool is gone, if you don’t keep orphans alive the pool will destroy them;
If you want to keep orphans alive when the pool is gone, both those functions should result invalid and the Actor can destroy itself on collision or you could run a loop and clean them up from somewhere in your logic graph.

Sorry I’m going to beat this horse to death right quick. If I have an object-pool that has “Instantiate on Demand” checked it will spawn unpooled objects (still of type pool because that’s the base class of such objects) whenever there’s no free objects in the pool. Later when I want to clean up such objects with “Return to Pool” nothing will happen because it didn’t come from the object-pool. That was what I meant by orphaned. I just think that an object should be destroyed if it has no owning pool. I can manually check for this myself but I think it’s cleaner if at least there was a parameter on “Return to Pool” to destroy an object if it’s found to have no owning pool. Just my two cents, but thanks for the plugin. It solved a hitch I was having in my infinite runner. Really useful for me. I was actually surprised to find there was nothing like this built-in to the engine.

Hi ,
I was going to email but figured this is a better place. I’m not able to get custom dilation to work with my APooledActor.

The setup
I have gone the C++ implementation route. I have a ProjectileActor that inherits APooledActor. The ProjectileActor contains the UPooledProjectile Component which has the movement component. The Actor then forms the base class for a Blueprint projectile (allows me to customize the bullet visuals etc).

When I spawn a projectile from the pool and immediately set the Custom Time Dilation to something small - 0.1 or 0.001 - the projectile doesn’t slow down. I also tried adjusting the speed mid flight by that didn’t seem to take effect. I’m happy to tweak the speed of the MovementComponent if that’s an option.

I’ve ensured the Blueprint has Tick working.

Global time dilation \ Slomo works fine. But I want to control the bullet speed individually not every actor in the scene.

Thanks again for the great plugin.

@Bino the problem you have is explained a bit last page on this forum, here:

https://forums.unrealengine.com/unreal-engine/marketplace/104929-plugin-object-pool-component?p=1794126#post1794126

The pooled movement component is a caching container, you should act upon the generated underlying projectile component instead.

Thanks ! That helped a lot in working it out but turned out wasn’t the issue.

For the Custom Time Dilation of an actor to be applied to the projectile movement component, it cannot simulate physics. Discovered this stepping through the TickComponent. It actually skips a bunch of logic that includes movement tied to the delta passed in.

Projectiles simulated with physics still get influenced global time dilation.

The code makes the best documentation…

Hey, not sure if you’re aware of this or not, but the plugin does not work at all in standalone or packaged games on 4.25.3. I just tried with the provided demo project after seeing it not work in my own project and sure enough no bullets are spawned in packaged/standalone.

I am running several projects on 4.25 latest version;
It’s possible you don’t have plugin binaries built for the latest engine release. Without DLLs properly compiled = no plugin.
Output logs always have something to say in there for things like this.

I just downloaded the newest version of the engine plugin from the Epic Marketplace into a fully updated 4.25.3, I’m not really sure what else I can say, the plugin works in PIE, but as soon as I packaged the game Spawn Pooled Actor stops working completely. This can be tested by simply launching a standalone game from the editor, no bullets are spawned whatsoever in your demo project.

Once again, it appears to work fine in PIE, but doesn’t work at all in packaged or standalone. I tried rebuilding the source as well just to get the same result, no build errors or any other errors for that matter, I have editor symbols installed as well with VS2019. UE4 wont open with missing dlls.

“Launch from Editor” is not supported by this plug-in by default.

Unless you change the “Developer” module from ‘Editor’ to ‘DeveloperTool’ and patch manually calls to UnrealEd APIs.

I’m very sure packaged builds work.
As I package a build every now and then, I would have noticed by now if shipping builds were broken.

Okay, sounds good, so it is a known issue. I actually packaged with the console with debug instead of shipping for further testing so that could be the issue.

So I’m actually having another issue with the newest version of the plugin. I can’t connect my object pool component to spawn actor from pool. It’s really strange. It shows a checkmark when I connect the node, but as soon as I let go it disconnects the node. If I roll back to a previous version of the plugin this issue goes away.

You must specify the target class on first pin before the node allows you to connect anything.